{% cycle %} Tag

cycles through list of arguments.

Logic Most Useful As Markdown

Argument(s)
various
Closing tag
Not required

Documentation

Cycles through list of arguments.

Variable

fruits = ['Apples', 'Bananas', 'Pears', 'Grapes', 'Oranges']

Template

<ol>
{% for fruit in fruits %}
  <li class="{% cycle 'odd' 'even' %}">{{ fruit }}</li>
{% endfor %}
</ol>

Result

<ol>
  <li class="odd">Apples</li>
  <li class="even">Bananas</li>
  <li class="odd">Pears</li>
  <li class="even">Grapes</li>
  <li class="odd">Oranges</li>
</ol>

Commentary

To start the sequence over part way through - typically inside a nested loop - see resetcycle.

The official documentation has some good examples of more advanced usage.

More Logic Tags

All Logic Tags


Did we get something wrong? Is there a use case for the cycle tag that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on August 2, 2026