Need to access year/month variable when grouping entries by date Having issues trying to access the year &amp; month variable when grouping entries by month-year. The code is outputting the desired results (ie. December 2014), however I would like to format the url by 'year/month'.

Archives


    Browse news &amp; articles for the last year.

{% set allEntries = craft.entries.section('news').limit(null) %}
&lt;ul&gt;
{% for date, entries in allEntries | group('postDate|date("F Y")') %}
    &lt;li&gt;&lt;a href="{{ year }}/{{ month }}"&gt;{{ date }}&lt;/a&gt;&lt;/li&gt;
{% endfor %}
&lt;/ul&gt;
If I understand your example correctly, a simple hyphen would do the trick &mdash; "YYYY-MM" is a format the date filter recognizes.

{% set entries = ... %}
{% set entriesByMonth = entries|group('postDate|date("Y-m")') %}
{% for month, entries in entriesByMonth %}
  &lt;li&gt;
      &lt;a href="{{ month|date("Y") }}/{{ month|date("m") }}"&gt;
        {{ entries | length }} entries in {{ month|date("F Y") }}
      &lt;/a&gt;
  &lt;/li&gt;
{% endfor %}