<p>I'm not seeing any obvious ways to access groups directly in Twig. There may be a more direct way, idk — but this should work.</p>

<pre><code>{% set categoryGroupNames = [] %}
{% for category in craft.categories %}
    {% set groupName = category.getGroup.name %}
    {% if groupName not in categoryGroupNames %}
        {% set categoryGroupNames = categoryGroupNames|merge([groupName]) %}
    {% endif %}
{% endfor %}

{% for groupName in categoryGroupNames %}
    {{ groupName }}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-05-14T20:52:09.310Z
2015-05-14T20:57:47.373Z
2015-05-14T20:57:47.373Z
Douglas McDonald
<p>I've looped through individual category groups to find each parent/child category, but is there a way to loop through and only show Category Group names?</p>

<categories><category><group><loop>
Loop through category groups
# Loop through category groups

(Asked by: username_0 on 2015-05-14)

I've looped through individual category groups to find each parent/child category, but is there a way to loop through and only show Category Group names?

**Tags:** categories, category, group, loop

---

## 1 answers

### Answer by username_1 on 2015-05-14. Score: 3 | Accepted answer

I'm not seeing any obvious ways to access groups directly in Twig. There may be a more direct way, idk — but this should work.
{% set categoryGroupNames = [] %}
{% for category in craft.categories %}
    {% set groupName = category.getGroup.name %}
    {% if groupName not in categoryGroupNames %}
        {% set categoryGroupNames = categoryGroupNames|merge([groupName]) %}
    {% endif %}
{% endfor %}

{% for groupName in categoryGroupNames %}
    {{ groupName }}
{% endfor %}


---

