Skip to content

Instantly share code, notes, and snippets.

@fabe
Created August 15, 2017 15:13
Show Gist options
  • Save fabe/9a73c5180203d2c1274a2552e93022c5 to your computer and use it in GitHub Desktop.
Save fabe/9a73c5180203d2c1274a2552e93022c5 to your computer and use it in GitHub Desktop.
Jekyll Subnavigation / Subpages (nested)
---
layout: default
title: Portfolio
listed: true
---
{% assign entries = site.pages | sort: "path" %}
<!-- We'll split the url and check if the first element is the title of the page, then show it. -->
<ul>
{% for entry in entries %}
{% assign slug = entry.url | split: "/" %}
{% assign parentSlug = page.title | slugify %}
{% if slug[1] contains parentSlug and slug[2] %}
<li>
<a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment