Thanks. That doc section definitely can take some improvement. I have opened an issue for that. In the meanwhile, here’s an explanation:
What does docs refer to?
.Site.Menus
is an array or slice of menus. From the page front-matter, you can specify the menu (one of the elements of that whole array) where that page should go.
So in that example, that page is linked with the “docs” menu.
It looks like the description of the menu entry.
No.
The template code which uses this data is given as:
{{ range .Site.Menus.main }}
FYI, that template is from a later section, and is not at all related to the “docs” menu example. In the template, it is assuming that the user has a “main” menu in their .Site.Menus
. It would be better to sync the examples on that doc page.
What is .Site.Menus.main?
“main” is a menu in .Site.Menus
, and that is an array or slice of menu entries.
It looks like an array of all the menu definitions?
Think of that as an array of all page references (menu entries) that the user added to the “main” menu.
A menu definition has
.URL
…
A menu entry has many more parameters than that.
I assume these four values are just printed for demo purposes.
It just happens that the template example needs to use just those 4 menu entry parameters.
I wonder how it works if menu entries are nested.
To nest the menu entries, you specify the parent
menu in the front-matter inside that menu
param.
Here’s a debug print out of .Site.Menus
that might look overwhelming at first. But give a minute or two, and try to understand that, and you’ll get the meaning of (Hugo Menus) life.