Agent skill
quartz-publish-guard
Manage unpublished content in Quartz static site repos. Use when: (1) User wants to prevent files without `publish: true` from being committed (2) User asks about gitignoring based on frontmatter content (3) User wants to unpublish a note or remove it from git (4) User wants to purge files from git history (5) User asks about the publish workflow with `npx quartz sync` Triggers: "publish", "unpublish", "gitignore frontmatter", "purge from history", "quartz sync"
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/quartz-publish
SKILL.md
Quartz Publish Guard
Protects unpublished Quartz content from being committed to git.
Core Concept
Files with publish: true in YAML frontmatter → tracked and synced to remote
Files without publish: true → local only, never committed
Scripts in Quartz Repo
| Script | Purpose |
|---|---|
find-unpublished.sh |
Lists all .md files without publish: true |
update-gitignore.sh --apply |
Adds unpublished files to .git/info/exclude (local only) |
unpublish.sh --apply |
Removes tracked files that became unpublished |
purge-unpublished-from-history.sh --apply |
Removes files from all git history |
hooks/pre-commit |
Auto-unstages unpublished files during commits |
Workflows
Normal Sync
npx quartz sync
Pre-commit hook auto-unstages unpublished files and updates .git/info/exclude.
Unpublish a Note (change publish: true → publish: false)
- Edit frontmatter to
publish: false - Run
./unpublish.sh --apply - Run
npx quartz sync
Publish a Note (change publish: false → publish: true)
- Edit frontmatter to
publish: true - Run
./update-gitignore.sh --apply(removes from exclude list) - Run
npx quartz sync
Purge from Git History
Only needed if sensitive data was accidentally committed.
./purge-unpublished-from-history.sh --apply
git remote add origin <url> # filter-repo removes remotes
git push origin v4 --force
Warning: Creates backup at ../quartz-backup automatically. Restore local files from backup after purge if needed.
Purge Specific File from History
git filter-repo --invert-paths --path <file-path> --force
git remote add origin <url>
git push origin v4 --force
Key Implementation Details
Why .git/info/exclude not .gitignore
.gitignoreis tracked → exposes filenames publicly.git/info/excludeis local-only → filenames stay private
Pre-commit Hook Behavior
- Auto-updates
date:field for modified markdown files to current ISO timestamp - Detects staged
.mdfiles incontent/withoutpublish: true - Auto-unstages unpublished files
- Runs
update-gitignore.sh --apply - Allows commit to proceed with remaining files
The hook keeps date_created: unchanged while updating date: to reflect the last modification time.
git filter-repo Gotchas
- Removes
originremote (must re-add after) - Deletes local files that are tracked AND being removed from history
- Files already untracked survive the purge
- Always use
./unpublish.sh --apply+npx quartz syncBEFOREgit filter-repoto preserve local files
Frontmatter Format
---
title: "Note Title"
publish: true # Must be exactly "publish: true" to be published
---
Files with publish: false or missing publish field are treated as unpublished.
Didn't find tool you were looking for?