Won't pickup .HasMenuCurrent or .IsMenuCurrent

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 … :thinking:

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]].

I bet I’m just missing something really obvious … :sweat_smile:

Create a small project without multilingual, and with only a few pages of content, and see if your menu works.

Tried real quick on an earlier pre-multilingual version of the same site. Did not work here either. :thinking:
(“My” menu is copied directly from the Hugo doc example …)

Can I turn on debugging and get more info from the build, maybe?

This may be helpful: Another way to make a menu item active

Thank you!

It seems that if I move the menu definition away from config.toml and into the front matter for each content file, the tests work!

And adding sectionPagesMenu = "main" to get the sections automatically.
(Can I hide a section then I have this enabled?) :smile:

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. :confused::slightly_smiling_face:

Can I somehow use sectionPagesMenu and then override the name? It seems to use .Title:thinking: