Skip to content
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

Merged
merged 5 commits into from
Mar 25, 2017

Conversation

lpancescu
Copy link
Collaborator

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.

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.
Copy link
Owner

@nishanths nishanths left a 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?

<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 := . }}
Copy link
Owner

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.
@lpancescu
Copy link
Collaborator Author

@nishanths I removed the unused assignment and refactored the example site to define the menu structure just in config.toml, instead of having that spreaded in different content files. Thanks!

@nishanths nishanths merged commit d233e56 into nishanths:master Mar 25, 2017
@lpancescu lpancescu deleted the menu branch March 25, 2017 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants