How do I loop through a Jekyll site’s posts but only take action on posts where the year is equal to a specific value?
{% for post in site.posts %}
{% if post.date.year == 2012 %}
<p>{{ post.date }}</p>
<p>{{ post.title }}</p>
{% endif %}
{% endfor %}
The above does not work. What is the correct way to do this?
To extract the year of a date, you have to use the
datefilter with"%Y"(the full syntax is listed here). i.e.: