If I have a for loop in Liquid (using Jekyll), how can I target even (or odd) items only? I have tried:
{% for item in site.posts %} {% if forloop.index
In contrast to what the Shopify support thread in Ales Lande's answer says, there is a modulo function in Liquid - in form of the modulo filter.
modulo
With it, you can do this:
{% for item in site.posts %} {% assign mod = forloop.index | modulo: 2 %} {% if mod == 0 %} {% else %} {% endif %} {% endfor %}