the ifchanged tag outputs its contents only if the last call to ifchanged rendered different output. Example for rendering a list of elements with alphabetical headings:
{% reorder elements by title %} {% for element in elements %} {% ifchanged %} <h3> {{ element.title | truncate: 1, "" }}</h3> {% endifchanged %} <a href="{{ element.url }}">{{ element.title }}</a><br> {% endfor %}