I have a page whose URL is /about/ and a corresponding menu entry for it in my main nav. I would like to add an “active” class to it when I’m viewing the page.
I tried the following and it did not work:
{{ $currentNode := . }}
{{ range .Site.Menus.menu }}
<a href="{{ .URL }}" class="btn-header hidden-xs{{if or ($currentNode.IsMenuCurrent "main" .) ($currentNode.HasMenuCurrent "main" .) }} active{{end}}">
{{ .Name }}
</a>
{{ end }}
And in my config.toml
:
[[menu.main]]
name = "About"
identifier = "about"
url="/about/"
What am I doing wrong?