Add docs for Section Menu for “the Lazy Blogger”

This commit is contained in:
bep 2015-05-10 16:18:14 +02:00
parent be7e746f2b
commit be0c1bfe13
2 changed files with 43 additions and 1 deletions

View file

@ -12,6 +12,9 @@ weight: 60
Hugo has a simple yet powerful menu system that permits content to be
placed in menus with a good degree of control without a lot of work.
*TIP:* If all you want is a simple menu for your sections, see [Section Menu for "the Lazy Blogger"]({{< relref "#section-menu-for-the-lazy-blogger" >}}).
Some of the features of Hugo Menus:
* Place content in one or many menus
@ -183,3 +186,42 @@ The following is an example:
</div>
</aside>
<!--sidebar end-->
## Section Menu for "the Lazy Blogger"
To enable this menu, add this to your site config, i.e. `config.toml`:
```
SectionPagesMenu = "main"
```
The menu name can be anything, but take a note of what it is.
This will create a menu with all the sections as menu items and all the sections' pages as "shadow-members". The _shadow_ implies that the pages isn't represented by a menu-item themselves, but this enables you to create a top-level menu like this:
```
<nav class="sidebar-nav">
{{ $currentNode := . }}
{{ range .Site.Menus.main }}
<a class="sidebar-nav-item{{if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }} active{{end}}" href="{{.URL}}">{{ .Name }}</a>
{{ end }}
</nav>
```
In the above, the menu item is marked as active if on the current section's list page or on a page in that section.
The above is all that's needed. But if you want custom menu items, e.g. changing weight or name, you can define them manually in the site config, i.e. `config.toml`:
```
[[menu.main]]
name = "This is the blog section"
weight = -110
identifier = "blog"
url = "/blog/"
```
**Note** that the `identifier` must match the section name.

View file

@ -21,7 +21,7 @@ Work In Progress.
* Show help information to Windows users who try to double click on `hugo.exe`.
* Add experimental support for [`Mmark`](https://github.com/miekg/mmark) markdown processor
* Add `AsciiDoc` support using external helpers.
* Add section menu support for _the lazy blogger_
* Add section menu support for a [Section Menu for "the Lazy Blogger"]({{< relref "extras/menus.md#section-menu-for-the-lazy-blogger" >}})
* Add shortcode support for HTML files
* Allow the same `shortcode` to be used with or without inline content
* Some important bugfixes: