<p>When you create a route, the slugs that you use ('year', ' month', 'day') will be made available in your templates as variables. You will need to use these to retrieve the entry(ies) your looking for. Something like:</p>

<p><em>Update: Sorry, first version had major errors, should be better now.</em></p>

<pre><code>{% set datetime = year ~ '-' ~ month ~ '-' ~ day %}
{% set entries = craft.entries.section('articles').postDate('and', '&gt;= ' ~ datetime, '&lt; ' ~ datetime|date_modify('+1 day')) %}

{% if entries %}

    {% for entry in entries %}
        &lt;article&gt;
            &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
            {{ entry.body }}
        &lt;/article&gt;
    {% endfor %}    

{% else %}
    &lt;article&gt;
        &lt;p&gt;There are no entries for this date.&lt;p&gt;
    &lt;/article&gt;
{% endif %}
</code></pre>

<p>Untested, but should be close. See <a href="https://craftcms.stackexchange.com/questions/1821/get-entries-by-date-but-ignore-time">this question</a> for another example.</p>

CC BY-SA 3.0
2014-11-24T16:03:29.800Z
2014-11-24T18:14:44.467Z
2017-04-13T12:51:00.200Z
Douglas McDonald
<p>I'm porting a site from EE and I'm running into an issue with an existing URL structure not working using routes.</p>

<p>Existing URL Structure: /articles/[year]/[month]/[day]/</p>

<p>I tried creating a route for the above to the articles/index template but it seems no matter what I try I'm returned the 404 page.</p>

<p>Because of the nature of the site, we need users to be routed to the articles/index template no matter what the three child slugs are and then we can display appropriate messaging if an article doesn't exist for the specific date/URL.</p>

<p><strong>Update</strong></p>

<p>It would appear this must be user error as now the expected outcome is working correctly.</p>

<p>Route: articles/[year]/[month]/[day]</p>

<p>Is properly routing users to the articles/index template whether or not an entry exists.</p>

<routes>
Catch all routes
# Catch all routes

(Asked by: username_0 on 2014-11-24)

I'm porting a site from EE and I'm running into an issue with an existing URL structure not working using routes.

Existing URL Structure: /articles/[year]/[month]/[day]/

I tried creating a route for the above to the articles/index template but it seems no matter what I try I'm returned the 404 page.

Because of the nature of the site, we need users to be routed to the articles/index template no matter what the three child slugs are and then we can display appropriate messaging if an article doesn't exist for the specific date/URL.

**Update**

It would appear this must be user error as now the expected outcome is working correctly.

Route: articles/[year]/[month]/[day]

Is properly routing users to the articles/index template whether or not an entry exists.

**Tags:** routes

---

## 1 answers

### Answer by username_1 on 2014-11-24. Score: 2

When you create a route, the slugs that you use ('year', ' month', 'day') will be made available in your templates as variables. You will need to use these to retrieve the entry(ies) your looking for. Something like:
Update: Sorry, first version had major errors, should be better now.
{% set datetime = year ~ '-' ~ month ~ '-' ~ day %}
{% set entries = craft.entries.section('articles').postDate('and', '>= ' ~ datetime, '< ' ~ datetime|date_modify('+1 day')) %}

{% if entries %}

    {% for entry in entries %}
        
            {{ entry.title }}
            {{ entry.body }}
        
    {% endfor %}    

{% else %}
    
        There are no entries for this date.
    
{% endif %}

Untested, but should be close. See this question for another example.


---

