but the return of template debugging for the menu is nil if I do not add sectionPagesMenu = "main" in the config file.
But doing so, will add menu items i do not want.
Here is the menu template I am using and taken from the docs:
<ul>
{{- $currentPage := . -}}
{{ range .Site.Menus.main -}}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL | absLangURL }}">{{ .Name }}</a>
</li>
{{- end }}
</ul>
I just want to define the menu in the config file and not in the front-matter.
Why do i have an empty menu without the sectionPagesMenu setting ? Did i do something wrong with my configuration ?
I have also verified that my partial calls do not miss the dot for passing the context variables.
NB: I also noticed that the menu items’ weight are not taken into account if i add sectionPagesMenu = "main" setting.
EDIT: After a few tests, this may be a possible bug. I am opening and issue.
You can find more details about it there if you’re interested: https://github.com/gohugoio/hugo/issues/3819
Hi Yann. The above issue refers back to this very forum post but there aren’t any new replies here. I might have stumbled upon the same issue. Did you find a solution?
I’ve seen this issue before, and it has to do with the config format (TOML in this case). I haven’t run into this specific issue, and I can’t find the discussion, but it had to do with the way arrays are defined, and when folks put their thing at the end it always works.
Hope that helps folks figure that particular thing out.
I did not investigate properly—but it makes a difference differenciating between Languages and languages, Languages.en and languages.en, Languages.en.menu.main and languages.en.menu.main (upper versus lower case).
I had similar problems defining multi-language menus.
There is (seems to be) a kind of path logic when looking for variables. While for templates, this logic is pretty well explained, for variables, it is not, (or at least I have not found it.) This is in my opinion the most important thing missing in an otherwise very well made documentation
I solved the problem by defining a partial template with a half-hard-coded menu structure integrating i18n for the labelling of the menus.
This was super hard (for me) to find but, I ran into this problem where, the menus I’d specified in config.toml simply would not render. What fixed it, was to make the word “language” consistently lowercase.