.IsMenuCurrent returns false for single pages

When the Menu item is declared in config file which is not a “PARENT” menu item and it’s just an individual page or single page, the .IsMenuCurrent doesn’t work.

If you want to utilize the .IsMenuCurrent feature of Hugo Menu then you must add the menu items using Front Matter of the page.

That’s the only way it works out.

Otherwise, you have to write your own code in order get things working properly.

I have menu at the moment which has some single pages and some section pages listed.
The section page .IsMenuCurrent and .HasMenuCurrent works properly but doesn’t work on Single Pages.

Another workaround is to custom code your MENU logic and not rely on Hugo Menus

@bep Please add this in the docs that .IsMenuCurrent and .HasMenuCurrent only works if the menu items are added using Front Matter only.

3 Likes