Skip to content
sskylar edited this page Jun 5, 2014 · 2 revisions

Pages

Nested menu:

<ul>
  {% for page in site.pages %}
  <li>
    <a href="{{page.url}}"{% if page.url == url %} class="is-current-page"{% endif %}>{{page.title}}</a>
    {% if page.pages.size > 0 %}
    <ul>
      {% for subpage in page.pages %}
      <li><a href="{{subpage.url}}"{% if subpage.url == url %} class="is-current-page"{% endif %}>{{subpage.title}}</a></li>
      {% endfor %}
    </ul>
    {% endif %}
  </li>
  {% endfor %}
</ul>

Assets

Sort page/post assets by filename:

  {% assign sorted_assets = assets.all | sort:'filename' %}
  <ol>
  {% for asset in sorted_assets %}
    <li>{{asset.url}}</li>
  {% endfor %}
  </ol>

Tags

Sort and loop through all tags:

{% assign sorted_tags = site.pages['blog'].taxonomy['tags'].values | sort:'value' %}
<ul>
    {% for tag in sorted_tags %}
    <li><a href="{{tag.url}}">{{tag.value}}</a></li>
    {% endfor %}
</ul>

Swap blog for your page's slug, and tags for the name of your tagset (if not using the default tags).

Advanced

Strip linebreaks from HTML:

{% capture html %}
<html>
...
</html>
{% endcapture %}{{ html | strip_newlines }}