Back to list
sushantvema

quartz-publish-guard

by sushantvema

0🍴 0📅 Jan 17, 2026

SKILL.md


name: quartz-publish-guard description: | 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"

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

ScriptPurpose
find-unpublished.shLists all .md files without publish: true
update-gitignore.sh --applyAdds unpublished files to .git/info/exclude (local only)
unpublish.sh --applyRemoves tracked files that became unpublished
purge-unpublished-from-history.sh --applyRemoves files from all git history
hooks/pre-commitAuto-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: truepublish: false)

  1. Edit frontmatter to publish: false
  2. Run ./unpublish.sh --apply
  3. Run npx quartz sync

Publish a Note (change publish: falsepublish: true)

  1. Edit frontmatter to publish: true
  2. Run ./update-gitignore.sh --apply (removes from exclude list)
  3. 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

  • .gitignore is tracked → exposes filenames publicly
  • .git/info/exclude is local-only → filenames stay private

Pre-commit Hook Behavior

  1. Auto-updates date: field for modified markdown files to current ISO timestamp
  2. Detects staged .md files in content/ without publish: true
  3. Auto-unstages unpublished files
  4. Runs update-gitignore.sh --apply
  5. 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 origin remote (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 sync BEFORE git filter-repo to 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.

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon