Best way to make menus

I’m just getting started here and have a question about menus. Trying different themes, I notice that there seems to be 2 or 3 ways this can be done.

  1. Create a folder in content (with/without a corresponding file???)
  2. Add [[menu.main]] entries in the conf.toml file
  3. Add menu entries in the front matter of pages.

I’m confused. What are the pros/cons of these methods?

  1. Is a leaf bundle (not sure) and only works if the theme is listing those

  2. Gives you a central place to manage every link, does not give you an indication of whether it is the active page when you cycle through the menu items

  3. Same as above but can be used to ascertain if the user is on the active page.

2 & 3 are aspects of the same thing - the menu feature. You can, of course, have multiple menu’s not just “main”. I think most theme’s use “main” as the site navigation menu.

I use a combination of 2 & 3. Using 2 for global settings and 3 for local overrides.

1 Like

These are the only methods that use the Hugo-native menu feature.

Using your option 2 i.e. menu in site config gives you a quick way to start using menus. It’s also used to configure the menu weights, etc.

Using your option 3 i.e. menu in front-matter gives you a finer control on which post should go to which (could be multiple) menu(s). You also need to use the site config (option 2) though if you want to assign menu weights.

I use option 3 exclusively as I don’t like to clutter my site config with “content stuff” like menus. And I get around the “not setting of menu weights in site config” by naming my menus with numerical prefixes (as the default sort of menus is alphanumerical if weights are not specified)… and then I remove those prefixes in my layout.

Thank you very much for these comments. Very helpful!