Hey guys I think I found a bug with the menu template example in the docs: Menu Templates | Hugo
When using this code sample for the menu:
<!-- sidebar start -->
<aside>
<ul>
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
<a href="#">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
<ul class="sub-menu">
{{ range .Children }}
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}active{{ end }}">
<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ else }}
<li>
<a href="{{ .URL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
</li>
{{ end }}
{{ end }}
<li>
<a href="#" target="_blank">Hardcoded Link 1</a>
</li>
<li>
<a href="#" target="_blank">Hardcoded Link 2</a>
</li>
</ul>
</aside>
And specifying my menu.main in my config.toml file as so:
[[menu.main]]
identifier = "book-me"
name = "Book Me"
url = "/book-me/"
weight = 1
[[menu.main]]
identifier = "coaching"
name = "Coaching"
url = "/coaching/"
weight = 2
[[menu.main]]
identifier = "detox"
name = "Detox"
url = "/detox/"
weight = 3
[[menu.main]]
identifier = "forms"
name = "Forms"
url = "/forms/"
weight = 4
[[menu.main]]
identifier = "about"
name = "About"
url = "/about/"
weight = 5
[[menu.main]]
identifier = "extras"
name = "Extras"
url = "/extras/"
weight = 6
[[menu.main]]
identifier = "blog"
name = "Blog"
url = "/blog/"
weight = 7
It never adds the active class but if I remove all menu entries in my config.toml and add the menu entries in my page Front Matter as so:
menu:
main:
identifier: blog
name: Blog
title: Blog
url: /blog/
weight: 7
It adds the active class to my menu entries, is this a bug or am I just not understanding how menu templates are supposed to work?
Thanks.