IsMenuCurrent failing for me (outside of the home page)

I’ve got the following menu:

[[menu.main]]
	name = "Home"
	url = "/"
    weight = 1

[[menu.main]]
	name = "About Me"
	url = "/about/"
    weight = 2

[[menu.main]]
	name = "Speaking Engagements"
	url = "/speaking/"
    weight = 3

[[menu.main]]
	name = "Contact"
	url = "/contact/"
    weight = 4

It renders with this code:

<ul class="menu">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}nav-current{{ end }}">
<a class="" href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>        

While the links work great, the nav-current class only shows up when I’m on the home page. What should I be looking for? What exactly does IsMenuCurrent use to determine if - well - it’s current. :wink:

Well, I give up. If i remove the menus from my config file and add them to the front matter, it works. I saw other posts (Issues, posts here) mentioning the same, but no resolution, so maybe a bug. I’d like to file a bug, but it’s already been filed (https://github.com/gohugoio/hugo/issues/3027) and closed with the direction to post here. So if someone tells me what I did wrong, I’d love to know (as I don’t appear to be the only one getting it wrong).

I just checked it on my local dev version and I think I agree that this is a bug (or I missed something, just as likely).

I used a site that doesn’t normally exists and added it as a page in the config.toml file. The pages which are declared in the front matter work fine for the active check, the one definded in the config file doesn’t.

Here are a bunch of screenshots: (The one to the right I just added for debugging purposes)

On the home page:
Home

On the changelog page:
changelog

On the Über page (Über is about in german)
about

As you can see the active markup from the css only work on the home and Über.


And here of course my used code:

The part the generates the menu:

<ul class="right hide-on-med-and-down">
  <li {{ if .Page.IsHome }} class="active"{{ end }}>
    <a href="{{ .Site.BaseURL }}">Home</a>
  </li>
  {{ $currentPage := . }}
  {{ $currentPage }} <!-- Just for debugging -->
  {{ range .Site.Menus.main }}
  <li{{ if $currentPage.IsMenuCurrent "main" . }} class="active"{{ end }}>
    <a href="{{ .URL | relURL }}">{{ .Name }}</a>
  </li>
  {{ end }}
</ul>

The way the changelog site is defined in the config.toml:

[[menu.main]]
  name = "Changelog"
  url = "/changelog/"
  weight = 10

And the way the Über page is defined in the front matter:

---
title: "Über"
slug: "uber"
date: 2017-05-19T22:45:13+01:00
menu: "main"
---