I am struggling to figure out how to increment the index variable within a for loop in Liquid/Jekyll. Currently, I have something along the lines of
{% for i in (0..num_posts) %}
{% if i < some_value %}
do_thing
{% else %}
{% endif %}
{% assign i = i|plus:1 %}
{% if i<some_value %}
do_another_thing
{% else %}
{% endif %}
{% endfor %}
The problem is, instead of incrementing i, it leaves i as the same value.
Things I have tried:
- Using
{% assign i = i|plus:1 %}
. - Using
{% increment i %}
. Using
{% assign j = i|plus:1 %} {% assign i = j %}
I can't use the offset
command either since the code doesn't always check only 2 if statements in the loop.
Any ideas?