How do I list the tag groups that are actually in use? 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:

&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;


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.
You could use the group filter to group your tags by tag groups:

{% 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;