Obsidian Nested Tags: Search a Parent Tag, Exclude Sub-Tags, or Match Only the Parent
Nested tags look tidy: #status/active, #status/parked, #status/done. Then you search and the results are wrong. tag:#status returns every project, including the finished ones. Excluding one sub-tag makes notes vanish that you expected to see. Searching for #work misses #myjob/work. None of this is a bug. Obsidian's Search treats nested tags in a specific way, and once you know the rules, each of these takes one line to fix. This checklist uses core Search only, no community plugins.
Quick reference
| What you want | Search term | Check |
|---|---|---|
| A tag and all its sub-tags | tag:#status |
1 |
| One sub-tag only | tag:#status/active |
1 |
| A parent tag but not one sub-tag | tag:#status -tag:#status/done (whole notes are dropped) |
2 |
| Only the parent, none of its children | /#status(?![\w/-])/ |
3 |
| A last segment under any parent | /#\S+\/work(?!\S)/ |
4 |
| Tags written in properties | tag: covers them; plain-text regex doesn't |
5 |
| A list that stays up to date in a note | a query code block |
6 |
☐ 1. Know what tag: matches
Obsidian's help on tags: "In Search, tag:inbox will match #inbox as well as all nested tags such as #inbox/to-read."
tag:#statusreturns notes with#status,#status/active,#status/doneand any deeper level.tag:#status/activereturns that branch and its own children, such as#status/active/blocked, but not#status/done.- Matching works from the start of the tag. The Search help says: "searching for
tag:#workwill not return results for#myjob/work." - Tags are case-insensitive, so
#Statusand#statusare the same tag. - The Tags view (command palette: Tags: Show tags) lists nested tags under their parent (switch Show nested tags on for the tree), and clicking a tag searches for it. It's a quick way to see which levels exist.
The Search help also notes that tag: "ignores matches in code blocks and in non-Markdown content", so it's more accurate than typing #status as plain text.
☐ 2. Excluding a sub-tag removes the whole note
Search terms can be negated with a hyphen, so tag:#status -tag:#status/done reads as "has a status tag, and isn't done". That works, as long as you remember that tag: looks at the whole note, not at a line.
- A note with
#status/activein one section and#status/donein another is dropped entirely, because it contains the excluded tag somewhere. - Note: this isn't spelled out in the help. A forum moderator answering a bug report put it as "Tag is note level operator not a line level. The result is correct."
- Put the hyphen in front of the operator:
-tag:#status/done. - If you need results per line or per section, the help lists
line:("files that contain at least one line matching") andsection:("matches in the same section"). Note: these match text, not tags, so#status/activetyped inside them also matches#status/active/blocked.
If a note can legitimately carry both an "active" and a "done" status, that's usually a sign the tag should move to one place, such as the note's properties, so each note has exactly one status.
☐ 3. Match only the parent, not its children
There's no built-in "this tag but none of its sub-tags" option, and regular expressions can't go inside tag: (Obsidian answers "operator 'tag' can only be followed by text", as a forum moderator confirmed). A plain-text regular expression works instead. The Search help: "To use regular expressions in your search term, surround the expression with forward slashes", and Obsidian uses JavaScript-flavoured regular expressions.
/#status(?![\w/-])/
#statusmust be followed by something that can't continue a tag, so#status/activeand#statusesdon't match.- A forum-suggested variant ends in
(?!\S)("not followed by a non-space character"). It's stricter: it also skips#status,or#status.when the tag is followed by punctuation. - For a deeper tag, escape each slash:
/#status\/active(?![\w/-])/. - Search is case-insensitive by default, so this also matches
#Status.
Note: \w covers only A–Z, a–z, 0–9 and underscore. If your tags use accented letters or other scripts, a tag like #statusé would match too. Check with Explain search term in the search settings.
This is a full-text search, so unlike tag: it also matches text inside code blocks.
☐ 4. Find a last segment under any parent
tag:#work won't find #myjob/work. To find a segment wherever it sits in the hierarchy:
/#\S+\/work(?!\S)/
- This matches
#myjob/workand#a/b/work, but not#myjob/work/todayor#myjob/workshop. - A shorter idea from the forum is searching for the text
"/work"in quotes. It's quick, but it also matches any other/workin your notes, such as file paths and URLs.
Note: like check 3, this reads note text, so tags that only appear in properties aren't found this way (see check 5).
☐ 5. Tags in properties
Obsidian's help: you can add tags with the tags property, and "Tags in YAML should always be formatted as a list".
---
tags:
- project
- status/active
---
- In properties, tags are written without
#.tag:#status/activefinds them, but the plain-text regexes in checks 3 and 4 look for#and won't. - To search the property directly, use property search:
[tags:status/active]. The help says property values accept "parentheses for grouping, theORoperator, double-quotes for exact matching, and regex". - Note: whether
[tags:status]also returns the nested values isn't documented. Try it on a few notes before relying on it.
If you mix body tags and property tags, tag: is the one operator that covers both.
☐ 6. Save the search as a live list in a note
The Search help: "To embed search results in a note, add a query code block". This works well for a dashboard note:
```query
tag:#status/active -tag:#status/done
```
- The block updates whenever the matching notes change. There's no list to maintain.
- Note: Obsidian Publish doesn't render embedded search results (the help says so), so this is for your own vault, not a published site.
- If you use Bases, the help notes that
file.hasTag("a")"will match both#aand#a/b", the same parent-matches-children rule as Search.
☐ 7. Colour the graph by tag
Graph view groups use the same search terms. In the graph settings, under Groups, click New group, type a search term such as tag:#status/active, and pick a colour.
- A group for
tag:#statuscolours every note with any status sub-tag. Use the full sub-tag if you want active and done in different colours. - Note: the help doesn't say which colour wins when a note matches more than one group. If a note shows the "wrong" colour, make the search terms mutually exclusive, for example
tag:#project -tag:#status/doneandtag:#status/done. - If all group colours disappear after an update, the reporter in one forum thread fixed it with Restore default settings in the graph settings. That also deletes your groups, so copy
.obsidian/graph.jsonfirst. That's where the graph settings, including the colour groups, are stored.
Symptom table
| Symptom | Likely cause | Check |
|---|---|---|
tag:#status returns finished projects |
Parent matches all sub-tags | 1, 3 |
#work search misses #myjob/work |
tag: matches from the start of the tag |
4 |
Notes disappear after -tag:#x/y |
Exclusion is note-level | 2 |
Regex typed inside tag: gives an error or no results |
Regex isn't supported inside tag: |
3 |
| Regex finds nothing for some notes | Tags live in properties, without # |
5 |
| Graph colours gone after an update | Graph settings issue; reset after backing up | 7 |
A vault with a tag convention already in place
Indie Weekly ($39) is a ready-to-open Obsidian vault for indie developers. According to its product page, it has 41 Markdown notes, including a Home dashboard, a getting-started guide, a tag convention note and filled examples, plus 8 templates: weekly review with a next-week plan, ship log, daily log, metrics snapshot, project, idea, decision and experiment. Its tag convention note uses one tag per note type (#weekly, #ship, #project, #decision and so on) and nested #status/active, #status/parked and #status/done tags for the project lifecycle, and the graph comes with colour groups for the main note types. It uses core Obsidian settings only, so no community plugins are needed. It's made for Obsidian desktop; mobile hasn't been tested yet. If you only want the two core templates, Indie Weekly Lite is free: it has the Weekly Review and Ship Entry templates, without the other 6 templates or the full 41-note vault.
Sources
- Obsidian Help, Tags (nested tags,
tag:inboxmatches#inbox/to-read, case-insensitive, tags property as a list, BaseshasTag): https://help.obsidian.md/tags - Obsidian Help, Search (
tag:operator,line:/section:, negation, property search, regular expressions, embeddedqueryblocks): https://help.obsidian.md/plugins/search - Obsidian Help, Graph view (Groups): https://help.obsidian.md/plugins/graph
- Obsidian Help, Tags view: https://help.obsidian.md/plugins/tags
- Obsidian forum, How to search by part of nested tag: https://forum.obsidian.md/t/how-to-search-by-part-of-nested-tag/15074
- Obsidian forum, Convenient search for nested-tag: https://forum.obsidian.md/t/convenient-search-for-nested-tag/52135
- Obsidian forum, Exclude sub tags of nested tags from search: https://forum.obsidian.md/t/exclude-sub-tags-of-nested-tags-from-search/60985
- Obsidian forum, Excluding nested tags does not work in search: https://forum.obsidian.md/t/excluding-nested-tags-does-not-work-in-search/83432
- Obsidian forum, Search: Match tag but not its nested children: https://forum.obsidian.md/t/search-match-tag-but-not-its-nested-children/106544
- Obsidian forum, Graph view not showing group colors: https://forum.obsidian.md/t/graph-view-not-showing-group-colors/66201