Skip to content

Instantly share code, notes, and snippets.

@HereChen
Created October 11, 2014 11:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HereChen/750699e0cd7e190ab367 to your computer and use it in GitHub Desktop.
Save HereChen/750699e0cd7e190ab367 to your computer and use it in GitHub Desktop.
Jekyll add active class to navbar
{% assign current = page.url | downcase | split: '/' %}
<nav>
<ul>
<li><a href='/about' {% if current[1] == 'about' %}class='current'{% endif %}>about</a></li>
<li><a href='/blog' {% if current[1] == 'blog' %}class='current'{% endif %}>blog</a></li>
<li><a href='/contact' {% if current[1] == 'contact' %}class='current'{% endif %}>contact</a></li>
</ul>
</nav>
<!-- http://stackoverflow.com/questions/8340170/jekyll-automatically-highlight-current-tab-in-menu-bar -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment