Skip to content

Instantly share code, notes, and snippets.

@oneblackcrayon
Created January 8, 2014 03:21
Show Gist options
  • Select an option

  • Save oneblackcrayon/8311250 to your computer and use it in GitHub Desktop.

Select an option

Save oneblackcrayon/8311250 to your computer and use it in GitHub Desktop.
This is how you loop through different directories in Jekyll using Liquid. I searched through about 50 pages on Stack Overflow, NationBuilder, and GitHub. There should be better documentation on JekyllRB.com for this kind of stuff. You can change the page.layout to be anything in your page's front-matter (the stuff that starts and ends with the …
{% case page.layout %}
{% when 'page' %}
{% for page in site.pages %}
{% if page.layout == 'page' %}
{% if page.title != 'Home' %}
<a href="{{ page.url }}">{{ page.title }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% when 'app' %}
{% for page in site.pages %}
{% if page.layout == 'app' %}
{% if page.title != 'Home' %}
<a href="{{ page.url }}">{{ page.title }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% when 'default' %}
{% for page in site.pages %}
{% if page.title != 'Home' %}
<a href="{{ page.url }}">{{ page.title }}</a>
{% endif %}
{% endfor %}
{% else %}
{% endcase %}
@spaceclottey

Copy link
Copy Markdown

Thank you so much for your work and for sharing it!

@oneblackcrayon

Copy link
Copy Markdown
Author

I wrote this years ago.
Does it still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment