Keeping an Active State on a SubPage of a Taxonomy

Hey there,
I’m currently writing a Documenation with Hugo and I’ve encountered an Issue while creating a Sidebar-Navigation.

I have a Taxonomy called Topics and these Taxonomies have Help Articles
{{ range $name, $taxonomy := .Site.Taxonomies.topics }} <li> {{ $name }} </li> <ul class="help-side-subnav"> {{ range $taxonomy.Pages }} <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}">{{ .LinkTitle }}</a></li> {{ end }} </ul> {{ end }}

How do I give the Page of the Taxonomy an Active state when being on that page?

A second small issue I encountered is that when I enter a subpage of my Main Menu’s Entries i lose the active state of the main menu.

It currently works like this
{{ $currentNode := . }} {{ range .Site.Menus.main }} <li><a class="nav-link-white {{ if $currentNode.IsMenuCurrent "main" . }} active {{end}}" href="{{.URL}}"> {{ .Name }} </a></li> {{ end }}

When I’m on /help IsMenuCurrent is work but when im on a subpage like /help/my-article i lose the active state. How can I keep it?

Have a look at HasMenuCurrent – also maybe the SectionPagesMenu setting.

@bep thanks!
adding SectionPagesMenu = "main" to the config and using HasMenuCurrent fixed my second problem

Although I’m sill not sure on how to solve the problem with keeping an active state on the pages of an taxonomy. Is there something like IsPageCurrent?

No, taxonomies vs page doesn’t have a IsPageCurrent or similar …

i solved it by comparing the URL of the Current open page and the url of the link
{{ $currentURL := .URL }} <div class="row"> <div class="col-md-4"> <ul class="help-side-nav"> {{ range $name, $taxonomy := .Site.Taxonomies.topics }} <li> {{ $name }} </li> <ul class="help-side-subnav"> {{ range $taxonomy.Pages }} <li hugo-nav="{{ .RelPermalink}}"><a {{ if eq $currentURL .URL}} class="active" {{ end}} href="{{ .Permalink}}">{{ .LinkTitle }}</a></li> {{ end }} </ul> {{ end }} </ul> </div> <div class="col-md-8">{{ .Content }}</div> </div>