I\'m rewriting my blog to use Jekyll. Jekyll uses the Liquid templating language so it makes it a little more difficult to learn how to customize.
I\'d like to group
If you want to break it down by year, here's the code:
{% for post in site.posts %}
{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
{% if forloop.first %}
{{this_year}}
{% endif %}
- {{ post.title }}
{% if forloop.last %}
{% else %}
{% if this_year != next_year %}
{{next_year}}
{% endif %}
{% endif %}
{% endfor %}
If you want to break it down to year and months it can be achieved like this:
{% for post in site.posts %}
{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
{% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %}
{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
{% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %}
{% if forloop.first %}
{{this_year}}
{{ this_month }}
{% endif %}
- {{ post.title }}
{% if forloop.last %}
{% else %}
{% if this_year != next_year %}
{{next_year}}
{{ next_month }}
{% else %}
{% if this_month != next_month %}
{{ next_month }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
It is only a matter of where do you make the cut on the loop.