Tutorials
Sync Obsidian Vault to Public Repo with GitHub Actions
How to automatically sync selected notes from a private Obsidian vault to a public repository for sharing via GitHub Pages.
Overview
┌──────────────────┐ ┌──────────────────┐
│ duyet/obsidian │ │ duyet/obsidian- │
│ (private) │ │ public (public) │
├──────────────────┤ ├──────────────────┤
│ │ │ │ build GitHub Pages
│ Personal/ │ │ note-1.md │ (GitHub Actions) duyet.github.io/
│ Work/ │ │ note-2.md │──────────────────► obsidian-public
│ Journals/ │ │ .github/fumadocs │
│ Public/ ───────────►│ │
│ note-1.md │ │ │
│ note-2.md │ │ │
│ │ │ │
└────────┬─────────┘ └──────────────────┘
│ ▲
│ repo-file-sync (Public/) │
└────────────────────────────┘
GitHub ActionsThe idea: keep your full Obsidian vault private, but expose a Public/ folder to a separate public repo that can be served via GitHub Pages.
Setup
1. Create a Personal Access Token (PAT)
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate new token with
reposcope - Copy the token
2. Add Secret to Private Repo
- Go to your private
obsidianrepo → Settings → Secrets and variables → Actions - Add new secret:
GH_PATwith your token value
3. Create Sync Configuration
Create .github/sync.yml in your private repo:
your-username/obsidian-public:
- source: Public/
dest: ./
deleteOrphaned: truesource: folder in private repo to syncdest: destination in public repo (./= root)deleteOrphaned: remove files in dest that no longer exist in source
4. Create Workflow
Create .github/workflows/sync.yml:
name: Sync Public Files
on:
push:
branches:
- master
paths:
- 'Public/**'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Run GitHub File Sync
uses: BetaHuhn/repo-file-sync-action@v1
with:
GH_PAT: ${{ secrets.GH_PAT }}
SKIP_PR: true
COMMIT_PREFIX: 'chore(sync):'5. Enable GitHub Pages on Public Repo
- Go to
obsidian-public→ Settings → Pages - Source: Deploy from branch
- Branch:
main(ormaster), folder:/ (root) - Your notes will be available at
https://your-username.github.io/obsidian-public/
How It Works
- Add/edit notes in
Public/folder of your private vault - Commit and push to
masterbranch - GitHub Actions triggers on changes to
Public/** repo-file-sync-actionsyncs files to public repo- GitHub Pages serves the public repo
Tips
- Only put notes you want public in the
Public/folder - Use
workflow_dispatchto manually trigger sync deleteOrphaned: truekeeps public repo clean when you remove notes- Consider adding an
INDEX.mdas landing page
Note
This page is rendered using fumadocs.dev. See the .github/fumadocs folder for configuration.
You can build the public repo with any static framework (Next.js, Astro, etc.) and deploy to any platform (Vercel, Cloudflare Pages, Netlify, etc.).
References
- duyet/obsidian-public - Live example of this setup
- BetaHuhn/repo-file-sync-action
- GitHub Pages Documentation
- fumadocs.dev