# IsMenuCurrent failing for me (outside of the home page)

**URL:** <https://discourse.gohugo.io/t/ismenucurrent-failing-for-me-outside-of-the-home-page/11461>\
**Category:** Uncategorized\
**Created:** [April 9, 2018, 4:27pm UTC](https://discourse.gohugo.io/t/ismenucurrent-failing-for-me-outside-of-the-home-page/11461 "2018-04-09T16:27:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raymond\_Camden](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raymond_camden/32/1076_2.png) [@Raymond\_Camden](https://discourse.gohugo.io/u/Raymond_Camden)\
**Post date:** [April 9, 2018, 4:27pm UTC](https://discourse.gohugo.io/t/ismenucurrent-failing-for-me-outside-of-the-home-page/11461/1 "2018-04-09T16:27:32Z")

</div>

I’ve got the following menu:

```auto
[[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:

```auto
<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. 😉

---

<div class="post-metadata">

**Author:** ![Raymond\_Camden](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/raymond_camden/32/1076_2.png) [@Raymond\_Camden](https://discourse.gohugo.io/u/Raymond_Camden)\
**Post date:** [April 9, 2018, 4:47pm UTC](https://discourse.gohugo.io/t/ismenucurrent-failing-for-me-outside-of-the-home-page/11461/2 "2018-04-09T16:47:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![olikami](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/olikami/32/5273_2.png) [@olikami](https://discourse.gohugo.io/u/olikami)\
**Post date:** [April 9, 2018, 7:43pm UTC](https://discourse.gohugo.io/t/ismenucurrent-failing-for-me-outside-of-the-home-page/11461/3 "2018-04-09T19:43:42Z")

</div>

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](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/4/44222304741c6334c4fb347248798f23bb79ff0d.png)

On the changelog page:  
 ![changelog](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/8/8f573d06f68486dc8cac0929e0edf4f96ab6b0d3.png)

On the Über page (Über is about in german)  
 ![about](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/a/aaca51f130632d42a9c27e98be6f393a859655e3.png)

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"
---
```
