Answers.Body: <p>You could use the <a href="http://buildwithcraft.com/docs/templating/filters#group" rel="nofollow"><code>group</code></a> filter to group your tags by tag groups:</p>
  
  <pre><code>{% set entries = craft.entries.section('gallery').limit(null) %}
  
  &lt;ul&gt;
  
      {# Get all the tags related to our gallery entries and group them by tag group #}
      {% set allGalleryTags = craft.tags.relatedTo(entries)|group('group') %}
  
      {# Loop the tag groups #}
      {% for tagGroup, tagsInGroup in allGalleryTags %}
  
          &lt;li&gt;
              &lt;h2&gt;{{ tagGroup }}&lt;/h2&gt;
              &lt;ul&gt;
  
                  {# Loop the tags of this group #}
                  {% for tag in tagsInGroup %}
                      &lt;li&gt;{{ tag.name }}&lt;/li&gt;
                  {% endfor %}
  
              &lt;/ul&gt;
          &lt;/li&gt;
  
      {% endfor %}
  
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T08:38:12.107Z
Answers.Text: Awesome. Thank you very much dude. It works flawless.
Answers.UserDisplayName: Cipick
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-19T09:19:27.887Z
Answers.Text: Glad to help, @Cipick. If you have lots of tags you could further group them by the first letter: `{% for letter, tagByLetter in tagsInGroup|group('name|slice(0, 1)') %}`.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-18T11:34:00.907Z
Answers.LastActivityDate: 2014-11-18T11:54:49.110Z
Answers.LastEditDate: 2014-11-18T11:54:49.110Z
Answers.UserDisplayName: carlcs
Body: <p>I'm developing a masonry photo gallery with some filters (colors, style, manufacturer, etc) and I want to use tags to filter them by. I need some navigation which should look like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;ul&gt;
      &lt;li&gt;Tag Group 1
          &lt;ul&gt;
              &lt;li&gt;Tag 1&lt;/li&gt;
              &lt;li&gt;Tag 2&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Tag Group 2
          &lt;ul&gt;
              &lt;li&gt;Tag 3&lt;/li&gt;
              &lt;li&gt;tag 4&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I read this article <a href="https://craftcms.com/support/active-tags" rel="nofollow noreferrer">https://craftcms.com/support/active-tags</a> but I can't figure out how to get all group tags and for them all the tags that are actualy in use. I think i should use </p>
  
  <pre><code>{% for tag in craft.tags.group('blogTags') %}
  </code></pre>
  
  <p>but I want to get all the group handles in a loop dynamically.</p>
  
Tags: <templating><navigation><tags><group>
Title: How do I list the tag groups that are actually in use?
ThreadText: # How do I list the tag groups that are actually in use?
  
  (Asked by: username_0 on 2014-11-18)
  
  I'm developing a masonry photo gallery with some filters (colors, style, manufacturer, etc) and I want to use tags to filter them by. I need some navigation which should look like this:
  
  ```html
  <ul>
      <li>Tag Group 1
          <ul>
              <li>Tag 1</li>
              <li>Tag 2</li>
          </ul>
      </li>
      <li>Tag Group 2
          <ul>
              <li>Tag 3</li>
              <li>tag 4</li>
          </ul>
      </li>
  </ul>
  
  ```
  
  I read this article <https://craftcms.com/support/active-tags> but I can't figure out how to get all group tags and for them all the tags that are actualy in use. I think i should use
  
  ```
  {% for tag in craft.tags.group('blogTags') %}
  
  ```
  
  but I want to get all the group handles in a loop dynamically.
  
  **Tags:** templating, navigation, tags, group
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-18. Score: 4 | Accepted answer
  
  You could use the [`group`](http://buildwithcraft.com/docs/templating/filters#group) filter to group your tags by tag groups:
  
  ```
  {% set entries = craft.entries.section('gallery').limit(null) %}
  
  <ul>
  
      {# Get all the tags related to our gallery entries and group them by tag group #}
      {% set allGalleryTags = craft.tags.relatedTo(entries)|group('group') %}
  
      {# Loop the tag groups #}
      {% for tagGroup, tagsInGroup in allGalleryTags %}
  
          <li>
              <h2>{{ tagGroup }}</h2>
              <ul>
  
                  {# Loop the tags of this group #}
                  {% for tag in tagsInGroup %}
                      <li>{{ tag.name }}</li>
                  {% endfor %}
  
              </ul>
          </li>
  
      {% endfor %}
  
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: Awesome. Thank you very much dude. It works flawless.  
  > **username_1**: Glad to help, @username_0. If you have lots of tags you could further group them by the first letter: `{% for letter, tagByLetter in tagsInGroup|group('name|slice(0, 1)') %}`.  
  
  ---
  
  