# The file tree and tag colors

The sidebar shows the vault as a tree of folders and notes, the same folders you see on disk. This page covers where new things go, renaming, moving and deleting, and tag colors.

![The file tree beside an open note](https://hatch-docs.pages.dev/assets/note-light.07427e5575.webp)
![The file tree beside an open note](https://hatch-docs.pages.dev/assets/note-dark.a9327611d6.webp)

## Where new things go

New notes, folders, canvases and collections go in the current folder.

- Click a folder to make it current. It gets a thin outline.
- Click a note and its folder becomes current.
- Click the empty space under the tree to go back to the top of the vault.
- Open a note any other way (search, a link) and its folder becomes current again.

## Making things

- The + button at the top of the sidebar opens a menu: New note, New folder, New canvas, New collection.
- Right-click a folder for the same four inside that folder.
- Right-click a note for "New note next to this".
- Right-click empty space for a note or folder at the top of the vault.
- Shift+F10 or the Menu key opens the menu for the focused row.
- Ctrl+N (Cmd+N on a Mac) makes a note in the current folder.

A new item shows up with its name selected, ready to type over. Enter keeps the name, Escape leaves it as it is. After you name a new note, the caret is in the note.

## Folders

- A folder is a real folder on disk, made with the platform's `mkdir`. So an empty folder is still there after a reload, and Obsidian sees it too.
- The vault keeps the list of folders (`Vault.folders()`, `createFolder`, `move`, `removeFolder`).
- A folder stays after its last note is deleted.
- Sync sends files, not folders. An empty folder reaches your other devices once it has a note in it.

## Renaming, moving and deleting

Notes, canvases, collections and folders all work the same way. A folder takes everything in it along.

- **Rename**: F2 on the focused row, or Rename in its menu.
- **Move**: drag a row onto a folder, onto a note (it lands next to that note) or onto the empty space under the tree (the top of the vault). Or pick "Move to folder" in the row's menu and choose a folder. A folder can't go into itself.
- **A name that is taken** gets a free one ("Cabin 1"), the way a new note does. The toast says so.
- **Delete**: Delete or Backspace on the focused row, or Delete in its menu. A folder with notes or files in it asks first and says how many go with it. An empty folder just goes.
- **Undo**: the toast after a rename, a move or a delete has an Undo button for a few seconds.

What follows a file to its new path:

- Links to it. A link that still finds the same file is left alone, so `[[Cabin]]` by name survives a folder rename untouched. A link written as a path gets the new path: `[[Projects/Cabin]]`, `[text](Projects/Cabin.md)`, `[text](../Cabin.md)`. Relative links inside a note that moved are fixed too. Headings and aliases are kept, and links inside code are not touched.
- The open note is fixed in its editor, as an edit you can undo. It is never rewritten on disk behind the editor.
- Saves of the open note wait while the files move, and go to the new path once they are there. You can keep typing during a move.
- A note's `.assets` folder, its comments (`.hatch/comments/`) and its version history.
- Canvas cards that show the file.
- The open note, the address, Back and Forward, the current folder, folder icons, which folders are open in the tree, and the templates folder setting.

Deleting a folder:

- The folder is read from the disk first. A file another app or sync put there counts in the question, even when the tree showed the folder as empty, and is kept for Undo too.
- An empty folder is only ever removed while it is empty on disk. If something turned up in it, nothing is deleted and the file shows in the tree.
- Every note's last text is kept in History first (the Deleted notes list), so a note can come back later. That needs History to be on.
- Comments are set aside in `.hatch/comments/.deleted/` and come back with the note.
- Undo in the toast brings back the whole folder: notes, canvases, collections, empty folders and other files. Other files are kept for Undo up to 64 MB in all. Past that the toast says how many could not come back.

How it is built:

- `Vault.move(from, to)` moves a file or a folder. It asks the file system to rename the folder in one step (`FileSystem.movesFolders`: desktop, mobile, memory). The browser's file system can't do that, so there each file is moved (never over a file already at the new path) and the old folders removed only once they are empty (`FileSystem.removeDir`). The index is moved, not read again.
- `Vault.syncFolder(path)` reads one folder from the disk again. Deleting a folder uses it before it asks.
- `Vault.planLinkFixes(moves)` works out the link changes before anything moves, while every link can still be followed.
- `moveWithLinks` in `packages/vault/src/moves.ts` puts the link fixes together with canvas cards and any `FileRewriter` a package adds. The MCP server's `move_note` uses it too. `folderRefsRewriter` in `packages/bases` follows a renamed or moved folder in collection filters (`file.inFolder("Old")`, `file.folder == "Old"`), in `.base` files and in ```` ```base ```` blocks.
- `packages/app/src/fileMoves.ts` adds comments and deleting. `store.renameNote`, `store.renameFolder` and `store.moveTo` all go through one method, `relocateNow`.
- `packages/app/src/treeDrag.ts` is the drag and drop. `components/MovePicker.tsx` is the folder picker.

Limits to know about:

- Sync sends a move as the old files going and new ones arriving. Other devices move the old copies to `.trash/` and download the new ones. The old folder is removed there once it is empty. A file that only moved is not counted as a suspicious mass delete, so a big folder moves without the "held deletions" question. A folder you delete in the app is not asked about twice either.
- On another device, a note that moved shows up in History under Deleted notes at its old path, because History is kept per device. If that device had the note open, it switches to another note.
- A collection whose folder name can't be changed where it is written (an odd YAML escape, say) is left as it was and counted in the "could not be updated" toast. Change it in the collection's filters.
- Dragging needs a mouse. On a touch screen use "Move to folder".
- There is no cut and paste for rows (Ctrl+X, Ctrl+V) yet.
- Undo is offered in the toast only. It is not on Ctrl+Z.

## Tag colors

- Every tag starts with one of the ten colors, picked from its name (`autoTagColor`, never gray). The same name gets the same color everywhere, from the first letter typed.
- In a note a tag is text: a click puts the caret in it, so you can type. To open its menu ("Show notes with #tag", the ten colors and Default), rest the pointer on the tag and press the Color button that shows above it, or Cmd-click (Ctrl-click on Windows and Linux), or right-click. The menu key and Shift+F10 open it for the tag the caret is in. A tag in a note's properties or the Tags panel opens the menu with a click.
- The colors are in the order Notion uses. Default is the theme's own tag color.
- Anything that draws a tag writes `tagAttrs(name)` from `packages/app/src/tagColors.ts` (`data-tag` and `data-tagc`). The editor writes the same two attributes itself.
- The ten colors are in `packages/theme/src/tag-colors.ts`. `tagPalette(theme)` tunes them to the theme in use, so the text reads on its chip (4.5:1) in light and dark.
- Choices are saved in the vault at `.hatch/tags.json`, so they travel with your notes:

  ```json
  { "colors": { "work": "red", "reading": "teal", "inbox": "default" } }
  ```

- Tag names are stored in lower case. `#Work` and `#work` share a color.
- Anything in the file that Hatch doesn't know is kept when it saves.
- Anything that draws a tag sets `data-tag="<name>"`: tags in a note, the tags property, the Tags panel. One stylesheet (`tagColorCss` in `packages/app/src/tagColors.ts`) maps those names to colors. Tag names are escaped, so an odd name can't break out of its rule.
- Published sites don't use tag colors yet. Tags there keep the site theme's tag color.
