<p>You're close!</p>
<p>We've got an example of how to do this here: <a href="http://buildwithcraft.com/help/entry-archive#grouping-by-year-and-then-month" rel="nofollow noreferrer">http://buildwithcraft.com/help/entry-archive#grouping-by-year-and-then-month</a></p>
<p>The trick is to group by year first, then by month.  Using the 'F' token is how to <a href="https://www.php.net/manual/en/function.date.php" rel="nofollow noreferrer">tell PHP</a> to display the name of the month.</p>

CC BY-SA 3.0
2014-08-10T16:43:47.697Z
Thanks Brad, this seems like it will do the trick. Can I still use the {{ year }} tag inside the month loop so it gives me August - 2014 as a title?
Daryl Campbell
CC BY-SA 3.0
2014-08-10T17:17:44.343Z
Yup... will still work fine there.  If that gets you what you want, mind marking this as the correct answer?
Brad Bell
CC BY-SA 3.0
2014-08-10T16:19:56.177Z
2014-08-10T16:19:56.177Z
2023-11-17T20:38:18.640Z
Brad Bell
<p>I have this piece of code which orders my entries by month, which is working great. I only have two issues which I can't work out. How would I display the year of the month beside the month title eg:</p>

<pre><code>&lt;h2&gt;{{ month }} &gt; {{ year }}&lt;/h2&gt;
</code></pre>

<p>As the list could run over a number of years it would be good to distinguish this. The next part is I can't seem to convert the month from a number ie: 8 to the word ie. "august". When I filter it, it just returns "Jan".</p>

<pre><code>{% set allEntries = craft.entries.section('featureArticles').find() %}
{% set allEntriesByMonth = allEntries|group('postDate.month') %}

{% for month, entriesInMonth in allEntriesByMonth %}

    &lt;h2&gt;{{ month }}&lt;/h2&gt;

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

{% endfor %}
</code></pre>

<entries><date>
Outputting Year of Entry Group alongside Month
# Outputting Year of Entry Group alongside Month

(Asked by: username_0 on 2014-08-10)

I have this piece of code which orders my entries by month, which is working great. I only have two issues which I can't work out. How would I display the year of the month beside the month title eg:
{{ month }} > {{ year }}

As the list could run over a number of years it would be good to distinguish this. The next part is I can't seem to convert the month from a number ie: 8 to the word ie. "august". When I filter it, it just returns "Jan".
{% set allEntries = craft.entries.section('featureArticles').find() %}
{% set allEntriesByMonth = allEntries|group('postDate.month') %}

{% for month, entriesInMonth in allEntriesByMonth %}

    {{ month }}

    
        {% for entry in entriesInMonth %}
            {{ entry.title }}
        {% endfor %}
    

{% endfor %}

**Tags:** entries, date

---

## 1 answers

### Answer by username_1 on 2014-08-10. Score: 3 | Accepted answer

You're close!

We've got an example of how to do this here: <http://buildwithcraft.com/help/entry-archive#grouping-by-year-and-then-month>

The trick is to group by year first, then by month. Using the 'F' token is how to [tell PHP](https://www.php.net/manual/en/function.date.php) to display the name of the month.

> **Comments:**
> **username_0**: Thanks Brad, this seems like it will do the trick. Can I still use the {{ year }} tag inside the month loop so it gives me August - 2014 as a title?  
> **username_1**: Yup... will still work fine there.  If that gets you what you want, mind marking this as the correct answer?  

---

