<p>Create a URL structure like this:</p>

<p><code>yourwebsite.com/categories/groupName</code></p>

<p>Then in your template:</p>

<p><code>{% set group = craft.request.getSegment(2) %}</code></p>

<p><code>{% set categories = craft.categories.group(segment) %}</code></p>

<p>Once you have the categories you can loop over them and fetch entries related to each. It may however, be more beneficial to do this via a plug-in where you can construct a more complex query based on the categories and therefore be more efficient.</p>

<pre><code>{% for category in categories %}

    {% set entries = craft.entries.relatedTo(category) %}

    {% for entry in entries %}
        // template stuff
    {% endfor %}

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

CC BY-SA 3.0
2016-05-01T19:49:54.223Z
In my situation I have a multi-locale site, so I don't think this will work. In some languages the category group segment would be different than the category group handle. However, this does seem like a possible solution for a monolingual site. I suppose I should have mentioned that I was working on a multi-locale site in my original question.
Justin K
CC BY-SA 3.0
2016-05-01T20:11:05.407Z
Can you create a language agnostic groupHandle and work off that? Then create a secondary field that can be translated with respect to the locale and displayed in the DOM as a header or something
mcclaskiem
CC BY-SA 3.0
2016-05-01T20:58:52.827Z
The problem I'm seeing is that the URL segment will change depending on the language so I cannot use it as a way to set the group variable in my template reliably. That is if I'm understanding you correctly and understanding your code above. My solution was to use several single pages for the "category home" pages. It is kind of annoying to have those single pages but it works well because singles have good multi-locale support.
Justin K
CC BY-SA 3.0
2016-05-01T21:17:49.277Z
Can you use a twig `macro` to translate the URL into whatever language the category title is?
mcclaskiem
CC BY-SA 3.0
2016-05-02T18:07:27.203Z
Yeah, that would probably work. Again, setting up a few singles pages just seems like a more straight forward solution to me. Thanks again for all your ideas @mcclaskiem.
Justin K
CC BY-SA 3.0
2016-05-01T14:43:05.357Z
2016-05-01T17:02:28.970Z
2016-05-01T17:02:28.970Z
mcclaskiem
<p>I'm familiar with the option in the category settings that allows for categories within a category group to each have their own URLs:
<a href="https://i.sstatic.net/bITPn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bITPn.png" alt="enter image description here"></a></p>

<p>I have this setup and it is working fine. However, I'm wondering if there is a URL structure that will allow me to have a category group "home" URL in which entries from all categories within the category group are shown.</p>

<p>I know there are a couple of different ways I could do this by setting up templates for each category group "home" page, but I would prefer a way to do this using a single template that took into account the URL structure.</p>

<templating><categories>
Entries from all categories in a category group via URL?
# Entries from all categories in a category group via URL?

(Asked by: username_0 on 2016-04-26)

I'm familiar with the option in the category settings that allows for categories within a category group to each have their own URLs:
[![enter image description here](https://i.sstatic.net/bITPn.png)](https://i.sstatic.net/bITPn.png)

I have this setup and it is working fine. However, I'm wondering if there is a URL structure that will allow me to have a category group "home" URL in which entries from all categories within the category group are shown.

I know there are a couple of different ways I could do this by setting up templates for each category group "home" page, but I would prefer a way to do this using a single template that took into account the URL structure.

**Tags:** templating, categories


---

## 1 answers

### Answer by username_1 on 2016-05-01. Score: 4

Create a URL structure like this:
yourwebsite.com/categories/groupName
Then in your template:
{% set group = craft.request.getSegment(2) %}
{% set categories = craft.categories.group(segment) %}
Once you have the categories you can loop over them and fetch entries related to each. It may however, be more beneficial to do this via a plug-in where you can construct a more complex query based on the categories and therefore be more efficient.
{% for category in categories %}

    {% set entries = craft.entries.relatedTo(category) %}

    {% for entry in entries %}
        // template stuff
    {% endfor %}

{% endfor %}

> **Comments:**
> **username_0**: In my situation I have a multi-locale site, so I don't think this will work. In some languages the category group segment would be different than the category group handle. However, this does seem like a possible solution for a monolingual site. I suppose I should have mentioned that I was working on a multi-locale site in my original question.  
> **username_1**: Can you create a language agnostic groupHandle and work off that? Then create a secondary field that can be translated with respect to the locale and displayed in the DOM as a header or something  
> **username_0**: The problem I'm seeing is that the URL segment will change depending on the language so I cannot use it as a way to set the group variable in my template reliably. That is if I'm understanding you correctly and understanding your code above. My solution was to use several single pages for the "category home" pages. It is kind of annoying to have those single pages but it works well because singles have good multi-locale support.  
> **username_1**: Can you use a twig `macro` to translate the URL into whatever language the category title is?  
> **username_0**: Yeah, that would probably work. Again, setting up a few singles pages just seems like a more straight forward solution to me. Thanks again for all your ideas @username_1.  

---

