Tags#
You can add tags to your notes to categorize or link notes together.
Creating a tag#
There are two ways of creating a tag:
- Adding a
#taganywhere in the text of the note, for example: #my-tag1 - Using the
tags: tag1, tag2yaml frontmatter note property. Noticemy-tag1andmy-tag2tags which are added to this document this way.
Tags can also be hierarchical, so you can have #parent/child such as #my-tag3/info.
Tag completion#
Typing the # character will launch VS Code's "Intellisense." This provider will show a list of possible tags that match the character. If you are editing in the frontmatter note property, you can invoke tag completion on the tags: line by either typing the # character, or using the "trigger suggest" keybinding (usually ctrl+space). If the # is used in the frontmatter, it will be removed when the tag is inserted.
Using Tag Explorer#
It's possible to navigate tags via the Tag Explorer panel. Expand the Tag Explorer view in the left side bar which will list all the tags found in current Foam environment. Then, each level of tags can be expanded until the options to search by tag and a list of all files containing a particular tag are shown.
Tags can also be visualized in the Foam Graph Explorer. See graph-visualization for more info including how to change the color of nodes representing tags.
Styling tags#
It is possible to customize the way that tags look in the Markdown Preview panel that renders your Foam notes. This requires some knowledge of the CSS language, which is used to customize the styles of web technologies such as VSCode. A cursory introduction to CSS can be found here.
- Create a CSS file within your Foam project, for example in
.foam/css/custom-tag-style.cssor .vscode/custom-tag-style.css - Add CSS code that targets the
.foam-tagclass - Add a rule for each CSS property you would like applied to your tags.
- Open the
.vscode/settings.jsonfile (or the Settings browser withctrl+,) - Add the path to your new stylesheet to the
markdown.stylessetting.
Note: the file path for the stylesheet will be relative to the currently open folder in the workspace when changing this setting for the current workspace. If changing this setting for the user, then the file path will be relative to your global VSCode settings.
The end result will be a CSS file that looks similar to the content below. Now you can make your tags standout in your note previews.
.foam-tag{
color:#ffffff;
background-color: #000000;
}

Using backlinks in place of tags#
Given the power of backlinks, some people prefer to use them as tags.
For example you can tag your notes about books with [[book]].