# The Library

The Library is a folder for the NPCs, scenes, spells and items you use in more than one campaign.

## The Library folder

`Library/` sits at the top of your workspace, next to your campaigns. Put things there that don't belong to one campaign: an NPC who could turn up anywhere, a homebrew spell, a scene you haven't placed in a session yet.

It is an ordinary folder. You can rename it, delete it, or keep reusable content somewhere else. Dunjii reserves no folder names: a folder is a campaign or a session because its `metadata.md` says `type: campaign` or `type: session`, never because of what it is called. See [Folder settings](https://dunjii.com/docs/organizing/folder-settings.md).

![The Library beside the campaigns Mistwood and Tallow.](https://dunjii.com/docs-assets/organizing/library-in-sidebar.webp)

## Shelves

The folders inside the Library are its shelves, one for each kind of thing. Each shelf has a `metadata.md` that sets its icon and its `defaultType`. This is `Library/NPCs/metadata.md`:

```markdown
---
icon: users
defaultType: npc
---
```

- `icon: users`: The icon beside the folder in the sidebar.
- `defaultType: npc`: A new document in this folder, or in any folder under it, is an NPC.

| Shelf       | `defaultType` | What goes there |
| ----------- | ------------- | --------------- |
| Abilities   | `ability`     | Class features, species traits and other abilities, as cards. |
| Battle Maps | `battle-map`  | Overhead maps to play on. |
| Items       | `item`        | Weapons, armor, potions and other items, as cards. |
| NPCs        | `npc`         | NPCs, monsters and creatures, with stat blocks and portraits. |
| Portraits   | `portrait`    | Artwork of NPCs that you use more than once. |
| Scenes      | `scene`       | Fights, locations and situations that aren't tied to a session yet. |
| Spells      | `spell`       | Spells, as cards. |

![The Library's seven shelves.](https://dunjii.com/docs-assets/organizing/library-shelves.webp)

## Adding to a shelf

Under a shelf's name in the sidebar is a button for its type: **New NPC** on NPCs, **New Spell** on Spells, **Upload Portrait** on Portraits and **Upload Battle Map** on Battle Maps. You can also drag files onto the shelf's page. Whatever you add takes the shelf's type unless it declares its own `type:`.

The type comes from `defaultType`, not from the folder's name, so a renamed shelf keeps working. To make a shelf of your own, create a folder such as `Library/Villains`, right-click it, choose **Info**, and set **Default type** to NPC.

![The NPCs shelf in the sidebar, with its New NPC button.](https://dunjii.com/docs-assets/organizing/library-new-npc.webp)

## The sample library

A new workspace starts empty. To look at finished examples first, click **Add sample library** on Home. Dunjii creates `Library/` with the seven shelves and puts one example on five of them:

| Shelf     | Example         |
| --------- | --------------- |
| Abilities | Perfect Rhythm  |
| Items     | Radiant Bastion |
| NPCs      | Eldric Vael     |
| Scenes    | Champ's Chops   |
| Spells    | Floral Eruption |

Battle Maps and Portraits start empty, and each one's page says what belongs there. The examples are ordinary documents that you can edit or delete.

The button appears only while your workspace has no `Library` folder, in any capitalization. Dunjii never adds the samples to a Library you already have.

The `dunjii init` command creates the same seven shelves in a folder on your computer, without the examples.

## Using Library content in a campaign

You don't copy Library content into a campaign. A link finds a document by its name anywhere in the workspace, so any session can point at the Library:

```markdown
The party meets [[Eldric Vael]] at the temple gate.
```

- `The party meets [[Eldric Vael]] at the temple gate.`: Links to Library/NPCs/Eldric Vael.md from any document in the workspace.

When two documents have the same name, the link goes to the one nearest the document you are writing in. Moving or renaming a document updates the links to it.

- **Add to Cast** in a scene lists NPCs from your whole workspace, the Library included. If you type a name that has no page yet, Dunjii makes one: in the session's folder when the scene is in a session, otherwise on the Library shelf that holds your NPCs. See [Sessions](https://dunjii.com/docs/organizing/sessions.md).
- A card sheet can list Library spells, items and abilities next to Sourcebook ones. See [Card sheets](https://dunjii.com/docs/layout-and-printing/card-sheets.md).
- [Search](https://dunjii.com/docs/organizing/search.md) finds Library documents from anywhere in the workspace.
