6.3 Tag Hierarchy

Tags can be defined in hierarchies. A tag can be defined as a group tag for a set of other tags. The group tag can be seen as the “broader term” for its set of tags. Defining multiple group tags and nesting them creates a tag hierarchy.

One use-case is to create a taxonomy of terms (tags) that can be used to classify nodes in a document or set of documents.

When you search for a group tag, it return matches for all members in the group and its subgroups. In an agenda view, filtering by a group tag displays or hide headlines tagged with at least one of the members of the group or any of its subgroups. This makes tag searches and filters even more flexible.

You can set group tags by using brackets and inserting a colon between the group tag and its related tags—beware that all whitespaces are mandatory so that Org can parse this line correctly:

#+TAGS: [ GTD : Control Persp ]

In this example, ‘GTD’ is the group tag and it is related to two other tags: ‘Control’, ‘Persp’. Defining ‘Control’ and ‘Persp’ as group tags creates a hierarchy of tags:

#+TAGS: [ Control : Context Task ]
#+TAGS: [ Persp : Vision Goal AOF Project ]

That can conceptually be seen as a hierarchy of tags:

You can use the :startgrouptag, :grouptags and :endgrouptag keyword directly when setting org-tag-alist directly:

(setq org-tag-alist '((:startgrouptag)

The tags in a group can be mutually exclusive if using the same group syntax as is used for grouping mutually exclusive tags together; using curly brackets.

#+TAGS: { Context : @Home @Work @Call }

When setting org-tag-alist you can use :startgroup and :endgroup instead of :startgrouptag and :endgrouptag to make the tags mutually exclusive.

Furthermore, the members of a group tag can also be regular expressions, creating the possibility of a more dynamic and rule-based tag structure (see Regular Expressions). The regular expressions in the group must be specified within curly brackets. Here is an expanded example:

#+TAGS: [ Vision : {V@.+} ]
#+TAGS: [ Goal : {G@.+} ]
#+TAGS: [ AOF : {AOF@.+} ]
#+TAGS: [ Project : {P@.+} ]

Searching for the tag ‘Project’ now lists all tags also including regular expression matches for ‘P@.+’, and similarly for tag searches on ‘Vision’, ‘Goal’ and ‘AOF’. For example, this would work well for a project tagged with a common project-identifier, e.g., ‘P@2014_OrgTags’.

If you want to ignore group tags temporarily, toggle group tags support with org-toggle-tags-groups, bound to C-c C-x q. If you want to disable tag groups completely, set org-group-tags to nil.