How to append class=“active” to a page that’s using a single.html layout

This fix didn’t work for me :anguished:

Anyone ever find a way to resolve this? All I need is to append class=“active” to a page that’s using a single.html layout.

HI @nevermike, moved your post to a new topic.

What have you tried so far?

1 Like

@zwbetz I think I figured out a solution.

<nav class="sitenavigation" role="navigation">
  <ul>
    {{ $currentPage := . }}
    {{ range .Site.Menus.main }}
      <li>
        <a href="{{ .URL | relURL }}" class="{{ if or (eq $currentPage.URL .URL) ($currentPage.HasMenuCurrent "main" .) }} active{{ end }}">{{ .Name }}</a>
      </li>
    {{ end }}
  </ul>
</nav>

Seems to be doing the trick.