I’m trying to add a current class to the active item in my nav bar. I can get it to work when linking to another page, but having issues when trying to link to a certain section via ID.
for example, my index.html has a section <div id="about">
and the nav is something like this:
<nav>
<ul>
<li><a href="{{ "index.html#about" | relative_url }}" class="{% if page.url == '/index.html#about' %}current{% endif %}">About</a></li>
<li><a href="{{ "index.html#skills" | relative_url }}" class="{% if page.url == '/index.html#skills' %}current{% endif %}">Skills</a></li>
<li><a href="{{ "contact.html" | relative_url }}" class="{% if page.url == '/contact.html' %}current{% endif %}">Contact</a></li>
</ul>
</nav>
the current class on the contact link works fine, but i can’t get it to work for the about or skills sections.
thanks for any help.