Skip to content

Instantly share code, notes, and snippets.

@xupyprmv
Created January 20, 2016 11:51
Show Gist options
  • Select an option

  • Save xupyprmv/6540ee0ad741d21b9573 to your computer and use it in GitHub Desktop.

Select an option

Save xupyprmv/6540ee0ad741d21b9573 to your computer and use it in GitHub Desktop.
Nested Jekyll page navigation without plugins

Usage

{% include navigation.html context="[top-level-path]" %}

Todo

  • Fix list nesting
<ul>
{% for entry in site.pages %}
{% capture slug %}{{ entry.url | split: "/" | last }}{% endcapture %}
{% capture current %}{{ entry.url | remove: slug | remove: "//" | append: "/" }}{% endcapture %}
{% if current == include.context %}
<li>
<a href="{{ entry.url }}" class="{% if page.url == entry.url %}active{% endif %}">{{ entry.title }}</a>
{% include categories.html context=entry.url %}
</li>
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment