Skip to content

Instantly share code, notes, and snippets.

@zackad
Created January 7, 2018 16:18
Show Gist options
  • Save zackad/e4afb6d0f8b7ae1d8926263ac3715342 to your computer and use it in GitHub Desktop.
Save zackad/e4afb6d0f8b7ae1d8926263ac3715342 to your computer and use it in GitHub Desktop.
archives liquid template for jekyll
---
layout: page
title: Archives
permalink: /archives/
---
<ul class="archive-list">
{% assign year = "" %}
{% assign month = "" %}
{% for post in site.posts %}
{% capture post_year %}{{ post.date | date: "%Y" }}{% endcapture %}
{% capture post_month %}{{ post.date | date: "%B" }}{% endcapture %}
{% if post_year == year %}
{% if post_month == month %}
<li>{{ post.title }}</li>
{% else %}
{% capture month %}{{ post.date | date: "%B" }}{% endcapture %}
{{ post_month }}
<li>{{ post.title }}</li>
{% endif %}
{% else %}
{% capture year %}{{ post.date | date: "%Y" }}{% endcapture %}
<li>{{ post_year }}</li>
{% if post_month == month %}
<li>{{ post.title }}</li>
{% else %}
{% capture month %}{{ post.date | date: "%B" }}{% endcapture %}
{{ post_month }}
<li>{{ post.title }}</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment