Tagging Folder

approvedunreviewed

by Dryden Bryson

Automatically tag notes based on the folder they live in.

Updated todayMIT

🏷️ Tagging Folder

Tag notes automatically based on the folder they live in.

Obsidian Latest release Build License: MIT

Features Β· Install Β· Usage Β· Settings Β· Limitations Β· Contributing


✨ Features

🏷️ Hands-off tagging

  • Right-click any folder to give it a tag
  • New notes in the folder are tagged as they're created
  • Notes moved in pick up the tag, notes moved out can drop it
  • Tag existing notes in one click when you set a folder up
  • Optionally includes subfolders
  • Works with templates: tags survive a template rewriting a new note

πŸ”„ Stays in sync

  • Nested folders stack: a note in Projects/Work/ gets #project and #work
  • Rename or move a folder and its tagging follows it
  • Moving a whole folder asks once, not once per note
  • Change a tag name and choose to replace or keep the old one
  • Only touches the tags property; the note body is never edited

Whenever tags would be removed, the plugin asks first. Tick Don't ask again to make your answer the default, and change it any time in settings.

πŸ“¦ Installation

[!IMPORTANT] Requires Obsidian 1.13 or later.

Manual install
  1. Download main.js, manifest.json and styles.css from the latest release, or build them yourself.
  2. Copy them into <Vault>/.obsidian/plugins/tagging-folder/.
  3. Reload Obsidian and enable Tagging Folder in Settings β†’ Community plugins.
Beta builds with BRAT
  1. Install BRAT.
  2. Select Add beta plugin and enter Dryd33n/obsidian-tagging-folder.

πŸš€ Usage

  1. Right-click a folder and select Auto-tag….
  2. Enter a tag name, such as project or area/work. A leading # is fine.
  3. Choose whether to tag existing notes and include subfolders. Both are on by default.
  4. Select Enable.

From then on, notes created in or moved into the folder get the tag in their tags property.

[!TIP] Right-click the folder again to edit its tag, re-apply it to every note in the folder, or disable auto-tagging.

πŸ”€ Moving notes

You move a note…What happens
Into an auto-tag folderThe folder's tag is added
Between two auto-tag foldersThe new folder's tag is added and the old one is removed (or kept, see Settings)
Out to a normal folderThe tag is removed or kept, see Settings
Within the same auto-tag folderNothing changes

Moving a folder of notes gives a single prompt for all of them. Closing a prompt without choosing always keeps the tags.

βš™οΈ Settings

Under Settings β†’ Tagging Folder you'll find every auto-tag folder, each with an βš™ Edit button and a Delete button that disables auto-tagging for that folder, and two behaviour settings. All of them show up in Obsidian's settings search.

SettingOptionsDefault
When disabling a folder's auto-taggingAsk every time Β· Remove tags Β· Keep tagsAsk every time
When a note leaves an auto-tag folderAsk every time Β· Remove tag Β· Keep tagAsk every time

Per folder:

OptionDefault
Tag nameβ€”
Include subfoldersβœ… On
Tag existing notes (when enabling)βœ… On

[!NOTE] Turning Include subfolders off counts as the subfolder notes leaving the folder, so it follows the "leaves an auto-tag folder" setting.

⚠️ Limitations

  • Tags you added by hand can be removed. If a note already had #project before its folder was auto-tagged, disabling the folder or moving the note out can remove it.
  • Changes made while Obsidian is closed aren't picked up. If notes are moved by sync or your file manager while Obsidian isn't running, use Re-apply tag to catch up.
  • Only Markdown notes are tagged. Canvases, PDFs and other files are ignored.
  • The vault root can't be auto-tagged.
  • Templates that take longer than 10 seconds to fill in a new note (for example, an unanswered Templater prompt) can overwrite the tag.

[!NOTE] Privacy: everything runs locally. The plugin only edits the tags property of notes in your auto-tag folders.

🀝 Contributing

Issues and pull requests are welcome.

  • πŸ› Bugs: open an issue with your Obsidian version, OS and the steps that reproduce the problem.
  • πŸ’‘ Features: open an issue to discuss before starting large changes.
Development setup
git clone https://github.com/Dryd33n/obsidian-tagging-folder.git
cd obsidian-tagging-folder
npm install
npm run dev     # rebuild main.js on change

Copy main.js, manifest.json and styles.css into a test vault at .obsidian/plugins/tagging-folder/, then reload Obsidian.

Testing
npm run lint       # Obsidian's plugin lint rules
npm test           # unit tests for the tagging logic
npm run test:e2e   # end-to-end tests in a real Obsidian instance

The end-to-end suite builds a fresh test-vault/, launches an isolated Obsidian instance with its own data folder (your normal Obsidian and vaults are untouched), runs every flow through the real UI and checks the notes on disk. It uses the newest Obsidian version your install has downloaded; set OBSIDIAN_ASAR= (empty) to test the older version bundled with the installer instead.

VariableEffect
OBSIDIAN_PATHObsidian executable, if it isn't at %LOCALAPPDATA%\Obsidian\Obsidian.exe
OBSIDIAN_ASARTest a specific Obsidian app version (obsidian-x.y.z.asar)
KEEP_OPEN=1Leave the test instance running afterwards to explore the test vault
E2E_DEBUG=1Log the active window before each test and list open modals on failure
Pull request checklist
  • Branch from master and keep each PR focused on one change.
  • npm run lint, npm run build, npm test and npm run test:e2e pass.
  • The PR describes what you tested in Obsidian.
  • No main.js or other build output committed.
  • Any UI text uses sentence case.
Releasing

Bump version in manifest.json and package.json, add the version to versions.json, then push a tag with the same version (no v prefix). CI builds the plugin, attests the release files and creates a draft release for you to publish.

Code layout
PathContents
src/main.tsPlugin lifecycle, vault events and rule actions
src/rules.tsFolder scope and tag logic (no Obsidian dependency)
src/modals.tsFolder modal and confirmation prompts
src/settings.tsSettings tab
tests/Unit and end-to-end tests
PLAN.mdBehaviour spec

Made for Obsidian by Dryd33n Β· MIT license

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.