Craft 3 Docs Group Filter Not Working I am attempting to replicate the example from https://docs.craftcms.com/v3/templating/filters.html#group

However, I am unable to access the {{ year }} in the first for loop inside the h2 element. It just shows up as an empty string. Anyone have an idea whats going on?

Here is my code:

{% set allEntries = craft.entries.section('weeklyDigests').all() %}
{% set allEntriesByYear = allEntries|group('postDate.year') %}

{% for year, entriesInYear in allEntriesByYear %}
   &lt;h2&gt;{{ year }}&lt;/h2&gt;

   &lt;ul&gt;

   {% for entry in entriesInYear %}
    &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
   {% endfor %}

   &lt;/ul&gt;
{% endfor %}
You were close!  In Craft 3, postDate is a full PHP DateTime object, so it'd need to be something like:

{% set allEntriesByYear = allEntries|group('postDate|date("Y")') %}