Automatic category based navigation with nesting

Hi, I’m looking for the best way to create a dynamic (automatic) nested menu system in my Hugo site. I want the end result to divide my navigation sidebar into sections per categories. The categories would probably be defined as a taxonomy and used as a Param for each piece of content.

I don’t know how many categories there would be in total or how many individual content items I have.

I looled into menus but they seem too prescribed and restrictive for my needs. Is there a way of determining all the category values used among all my content? Thanks!

What have you tried with the menu system? What restriction did you run into? Point us to a repo, and someone may be able to point out the proper way to create your menu.

Thank you for the reply. I don’t have anything to show yet because I don’t know how to get started.

The menu system doesn’t seem appropriate because you specify pages/links manually. I want to create a dynamic menu based on category taxonomies.

Try incorporating the example section menu for the “lazy blogger”. Then modify as needed, and see if you hit a wall.

Also, see how the menu is setup for the docs site? Check out the template used to produce it.

2 Likes

This simply doesn’t work for me :frowning:

Two problems:

  1. The menu doesn’t work at all unless I put SectionPagesMenu = "main" in config.toml. I’m designing a theme, so I’d like it to work in theme.toml. If I put it in there, the menu is empty.
  2. I have several nested sections in /patterns/, which exists in /content/. All the menu does is render a menu item called patterns which links to http://mydomain.io/patterns which isn’t even a page.

I’d take a look at themes from the showcase that have instructions for menus. I think many of them make menus optional, based on the existence of settings in config.*.

Do you mean, the example in menu docs? If that is the behavior then you have something to go off. Try tweaking the example to see if you can get what you are looking for.

Also, an update to Hugo is imminent, so check it out and maybe test it, as it adds support for nested sections, which may or may not be useful for your use case (with the categories and such).

Thanks for the info! Excited about the update.