Advanced Hugo Menus Multiple Menus

Quick-ish summary, before I get into your specific questions:

You define your menu structure by defining what menu items belong to your menu.

Given each menu item, you may add it to your menu:

  1. by adding the menu definition in your content files, or

  2. by adding a menu configuration in your config.

If all that belongs to your menu is content, you need not define anything in your config file. You can have all your menu definitions in your content frontmatter.

As you have seen from your experimenting however, this means that while you can attach your one content file to multiple menus, you cannot attach your one content file to the same menu multiple times.

Ie:

Yes:
---
menu:
  firstmenu:
    parent: firstmenuparent
  secondmenu:
    parent: secondmenuparent
---
No:
---
menu:
  firstmenu:
    parent: firstmenuparent
  firstmenu:
    parent: secondmenuparent
---

So. What you want is not the usual case, so what you need to do is not the “usual way”.

Enter the second way of adding menu items.

The second method comes under the header “Add Non-content Entries to a Menu”.

This does not mean that you add only non-content entries. What this means is that if you have menu items that are not attached to a content page (ie external links, which therefore implies no frontmatter), you can still add them to your menus. Do not get over fixated on the “non-content entries” part. This is what this method is able to accommodate, unlike the frontmatter method, but not the only thing it can be used for.

You have the option of defining your entire menu structure in the config, without once touching your content frontmatter, even if all your menu items point to internal pages.

1 Like