Short version:
I want to add 1 to a number in a liquid template and use the result as an array index.
{% capture plus_one %}{{ 0 | plus: 1 }}{% endcaptur
I was having a similar problem, using the answers above I got the following working on my site. Might be of help to someone else.
{% for num in (0..site.categories.work.size) %}
{% assign page2 = site.categories.work[num] %}
{% if page2.title == page.title and page2.date == page.date %}
{% assign next_i = forloop.index0 | plus: 1 %}
{% assign prev_i = forloop.index0 | minus: 2 %}
{% if next_i == site.categories.work.size %}
{% assign next_i = 1 %}
{% endif %}
{% endif %}
{% endfor %}