{% capture modulo %}{{ forloop.index | divided_by: 4 }}{% endcapture %} {% if modulo == 0 %} <div>echo something</div> {% endif %}