Next: , Previous: , Up: Anatomy of an Org-roam File   [Contents]


5.2 Tags

Tags are used as meta-data for files: they facilitate interactions with notes where titles are insufficient. For example, tags allow for categorization of notes: differentiating between bibliographical and structure notes during interactive commands.

Org-roam calls ‘org-roam--extract-tags’ to extract tags from files. It uses the variable ‘org-roam-tag-sources’, to control how tags are extracted. The tag extraction methods supported are:

  1. 'prop’: This extracts tags from the ‘#+roam_tags’ property. Tags are space delimited, and can be multi-word using double quotes.
  2. 'all-directories’: All sub-directories relative to ‘org-roam-directory’ are extracted as tags. That is, if a file is located at relative path ‘foo/bar/file.org’, the file will have tags ‘foo’ and ‘bar’.
  3. 'last-directory’: Extracts the last directory relative to ‘org-roam-directory’ as the tag. That is, if a file is located at relative path ‘foo/bar/file.org’, the file will have tag ‘bar’.

By default, only the ‘'prop’ extraction method is enabled. To enable the other extraction methods, you may modify ‘org-roam-tag-sources’:

(setq org-roam-tag-sources '(prop last-directory))

If you wish to add your own tag extraction method, you may push a symbol ‘'foo’ into ‘org-roam-tag-sources’, and define a ‘org-roam--extract-tags-foo’ which accepts the absolute file path as its argument. See ‘org-roam--extract-tags-prop’ for an example.