Skip to content

Instantly share code, notes, and snippets.

@DanRader
Last active January 15, 2017 23:09
Show Gist options
  • Select an option

  • Save DanRader/a6e5b10a1e3fd68aba6415652cc84e11 to your computer and use it in GitHub Desktop.

Select an option

Save DanRader/a6e5b10a1e3fd68aba6415652cc84e11 to your computer and use it in GitHub Desktop.
Navigation loop that highlights your current page AND any sub pages connected—for example, a blog list page and posts both highlighting 'blog'. It also sorts by position in YAML
{% assign sorted-p = site.pages | sort: 'position' %}
{% for p in sorted-p %}
{% if p.is-menu == true %}
<li class="{% if p.url == page.url or page.url contains p.url %} active {% endif %} nav-links"><a href="{{ p.url }}">{{ p.title }}</a>
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment