I have a very simple site split into sections. All pages use just one template.

The previous site had sections such as /section/subject. I had thought I could have all entries in just one section and then alter the URL on each entry to include a 'pretend' section /section/{slug}, but this defaults to /section-subject.

Is there a way to have /settings/subject/ without creating new sections?

Many thanks


  • It's a bit unclear how your sections are set up in your new site. When you say "include a 'pretend' section /section/{slug}, but this defaults to /section-subject", how did you do this? Did you just prepend "section/" manually to the slug of the entry? What, in your new site, determines what the "section" part of the url should be? Oct 31, 2014 at 10:28

2 Answers 2


From what I gather from your question you want some sort of sub-categorisation of your entries.

Such that one entry can have the URL as: siteUrl/section/subject-1/entry-slug

while another entry can have a URL as: siteUrl/section/subject-2/entry-slug

If that is what you want to achieve then you have to look into Structures instead of Channels

Here is the link: http://buildwithcraft.com/docs/sections-and-entries#sections

You can basically have multiple entries with sub-urls in the same structure section.


As Moin suggested a Structure works very well for this. I would add that you can also define different Entry Types for the different levels and/or page types (i.e. section landing page vs. entry page vs contact page) and test for entry.type in your template.

{% extends "_layout" %}

{# switch content based on Entry Type #}
{% switch entry.type %}
    {% case 'landing %}
        {# my landing page content or template include #}
    {% case 'entry' %}
        {# my entry page content or template include #}
    {% case 'contact' %}
        {# my contact page content or template include #}
{% endif %}

Or, if you don't want or need an actual landing page you can create 'pretend' empty entries (i.e. entries with title and slug only) for the sole purpose of generating the navigation and uri segments that your looking for. If someone clicks a link to one of the these 'empty' pages (or accesses the url directly) you can simply redirect them to the next entry in the hierarchy that actually has content.

{% extends "_layout" %}

{# if no body content and has descendants (i.e. no landing page) 
 # redirect to first descendant with content defined #}

{% if not entry.body is defined or entry.body == "" %}
    {% set decendants = entry.descendants %}
    {% if decendants|length %}
        {% redirect decendants.first().url %}
    {% endif %}
{% endif %}

{% block content %}
    {{ entry.title }}
    {{ entry.body }}
{% endblock %}

If you don't want to trust 'body' being empty, you could also more explicitly define an entry type that had no fields other than title, called 'pretendSection' for example, and test for that entry type, and redirect as above.

  • Just to let you know, i've implemented this and it works great! Many, many thanks to you and Moin.
    – Martin
    Nov 3, 2014 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.