Skip to content

Instantly share code, notes, and snippets.

@opattison
opattison / jekyll-category-nav.html
Last active December 20, 2015 21:39
A pattern for category-limited navigation using Liquid in Jekyll. The `if` statement only generates a nav link if the URL for the next/previous post exists *and* if the category for the next post is of the same type. This pattern assumes that one is using categories to describe types of post (e.g. writing, photos, videos and so on) to build mult…
<footer class="post-nav">
{% if page.next.url and page.next.categories contains 'writing' %}
<a class="more next" href="{{page.next.url}}" title="Later article: {{page.next.title}}">Next</a>
{% endif %}
{% if page.previous.url and page.previous.categories contains 'writing' %}
<a class="more previous" href="{{page.previous.url}}" title="Earlier article: {{page.previous.title}}">Previous</a>
{% endif %}
</footer>
@opattison
opattison / gallery.html
Last active January 21, 2020 08:11
A Jekyll photo gallery sample, using a for loop in liquid and collections in YAML front matter. This is sort of pseudo-code, but is in a working state in this project: https://github.com/opattison/jeancflanagan 2013-08-13