This is the official manual for the latest Org-mode release.

Table of Contents

Next: , Previous: Setting tags, Up: Tags

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 will return matches for all members in the group and its subgroups. In an agenda view, filtering by a group tag will display 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 an hierarchy of tags:

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

That can conceptually be seen as a hierarchy of tags:

     - GTD
       - Persp
         - Vision
         - Goal
         - AOF
         - Project
       - Control
         - Context
         - Task

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 & :endgroup instead of :startgrouptag & :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. The regular expressions in the group must be specified within { }. Here is an expanded example:

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

Searching for the tag ‘Project’ will now list 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.