-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render the site menu based on user configuration #62
Conversation
Hugo supports menus defined in config.toml, as well as the frontmatter. We can iterate through Sites.Menu.<menu_name> to generate the site menu, although my implementation doesn't support nested menus. I also changed the example site to use the new menu implementation, while keeping the previous menu ordering and generated CSS classes. Please see https://gohugo.io/extras/menus/ for details.
According to https://gohugo.io/content/multilingual/, a theme should either use .URL or construct URLs using relLangURL/absLangURL - not both. Cocoa doesn't support multiple languages yet, so this was probably harmless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpancescu Thank you for the changes!
Looks good to merge, but could you address the comment before?
layouts/partials/header.html
Outdated
<li class="nav-blog"><a href="/blog/">Blog</a></li> | ||
<li class="nav-about"><a href="/about/">About</a></li> | ||
<li class="nav-code"><a href="/code/">Code</a></li> | ||
{{ $currentPage := . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this assignment useful? Can we remove it if it's not?
It is probably better to define the site menu in the configuration file, instead of spreading it over the content files (especially if we have to order the menu items by using the weight parameter). The only disadvantage is that the menu isn't automatically updated when you remove a section or fixed page from the content.
@nishanths I removed the unused assignment and refactored the example site to define the menu structure just in |
Hugo supports menus defined in config.toml, as well as the frontmatter.
We can iterate through Sites.Menu.<menu_name> to generate the site menu,
although my implementation doesn't support nested menus.
I also changed the example site to use the new menu implementation,
while keeping the previous menu ordering and generated CSS classes.
Please see https://gohugo.io/extras/menus/ for details.