Clean Command
The clean command removes the entire output directory generated by Kiln, deleting all HTML files, assets, and build artifacts. This ensures that your next build starts from a blank slate with no leftover files from previous runs.
When you delete or rename a note in your Obsidian vault, the old HTML file can linger in the output folder because the Generate Command overwrites existing files but does not remove orphaned ones. Running clean before rebuilding guarantees that the output directory contains only the current state of your vault.
When to Use Clean
You do not always need to run clean manually. The generate command calls clean automatically at the start of every build, so your output directory is always wiped before new files are written.
Run clean on its own when you want to:
- Remove build output without rebuilding — free up disk space or reset your project directory to a pre-build state.
- Switch output directories — if you previously built to a custom path with
--outputand want to remove that specific folder. - Troubleshoot build issues — if your generated site looks stale or shows deleted notes, manually cleaning and regenerating can rule out caching or file system issues.
Usage
kiln clean
To remove a custom output directory instead of the default ./public:
kiln clean --output ./dist
Flags
| Flag | Short | Default | Description |
|---|---|---|---|
--output | -o | ./public | The path to the directory that should be removed. |
--log | -l | info | Sets the log level. Choose between info or debug. |
How It Works
Under the hood, clean performs a recursive delete of the target directory and all of its contents. It does not selectively remove individual files — the entire folder is deleted in one operation. After cleaning, you can rebuild with the Generate Command to produce a fresh output directory.
This command permanently deletes the specified directory and all of its contents.
Ensure you do not point the --output flag at your source vault or a directory containing important files. Deleted files cannot be recovered.
Recommended Build Workflow
For a reliable build process, combine clean with the other Kiln commands. A typical sequence from an existing vault to a live preview looks like this:
# 1. Check for broken links
kiln doctor --input ./vault
# 2. Build the site (clean runs automatically)
kiln generate --name "My Notes" --url "https://notes.example.com"
# 3. Preview locally
kiln serve
Since generate already calls clean internally, you only need to run clean separately when you want to delete build output without triggering a new build.
Related Commands
- Generate Command — build your vault into a static site (runs clean automatically)
- Serve Command — preview the generated site in your browser
- Doctor Command — scan for broken wikilinks before deploying
- Init Command — scaffold a new vault to get started