Trying to get Hugo to mark active menu entry using the example from https://gohugo.io/templates/menu-templates/
But I couldn’t get it working. It seems that $currentPage.HasMenuCurrent and $currentPage.IsMenuCurrent are never true …
I tested also by adding (to my nav.html partial):
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if $currentPage.HasMenuCurrent "main" . }}
HasActive
{{ end }}
{{ if $currentPage.IsMenuCurrent "main" . }}
IsActive
{{ end }}
...
… but no IsActive or HasActive shows up no matter …
Any hints on what I can do to check?
Can it be related to multilingual setup?
I’m defining my menu in config.toml using stuff like [[languages.no.menu.main]] and [[languages.en.menu.main]].
Tried real quick on an earlier pre-multilingual version of the same site. Did not work here either.
(“My” menu is copied directly from the Hugo doc example …)
Can I turn on debugging and get more info from the build, maybe?
Interestingly, I seem to only get IsActive for the sections themselves when I use sectionPagesMenu.
If I don’t use sectionPagesMenu and instead define section menu entries in _index.md for each section, then the IsActive method return true only for sub pages of each section, not for the section itself … I guess I’m still confused.
Can I somehow use sectionPagesMenu and then override the name? It seems to use .Title …