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 % 2 == 1 %}
but that doesn't seem to work. I have also tried:
(forloop.index % 2) == 1
and:
forloop.index - (forloop.index / 2 * 2) == 1
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…