Template for event archive I've hacked this together to create an event archive listing, and although it works, I'm wondering if it's 'correct' or could be done more succinctly?

{% set pastEvents = craft.entries.section('eventsEntry').orderBy('eventDate') %}
   {% for date, entries in pastEvents | group("pastEvents.eventDate|date('Y')") %}
        &lt;h4&gt;{{ date }}&lt;/h4&gt;
            &lt;ul&gt;
                {% for event in pastEvents.all() if event.eventDate &lt;= now %}
                &lt;li&gt;
                    {{ event.eventDate|date('d/m/y') }}
                    {{ event.title }}
                &lt;/li&gt;                   
                {% endfor %} 
            &lt;/ul&gt;   
   {% endfor %}
Instead of grabbing all entries in the eventsEntry section, then filtering by the current date/time, you could do the filtering on the database side first, so you're returning only the entries you're interested in.

Something like this:

{% set pastEvents = craft.entries.section('eventsEntry').eventdate('&lt;= ' ~ now|atom) %}

{% for date, entries in pastEvents | group("pastEvents.eventdate|date('Y')") %}
    &lt;h4&gt;{{ date }}&lt;/h4&gt;

    &lt;ul&gt;
        {% for event in pastEvents.all() %}
            &lt;li&gt;
                {{ event.eventdate|date('d/m/y') }}
                {{ event.title }}
            &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}