cosmosmount32 downloadsEdit a GitHub Pages vault natively, preview it with the production renderer, and collaborate through Git.
GitHubPage is a desktop-only Obsidian plugin for editing, previewing, and publishing a GitHub Pages website directly from a vault. The plugin and its standalone CLI share the same renderer, theme format, and exact engine version, so the local preview matches the site produced by GitHub Actions.
origin remote and Git identity for publishing actions.main.js, manifest.json, and styles.css from the latest release.<vault-config-dir>/plugins/github-page/. The default Obsidian configuration directory is .obsidian, but GitHubPage also supports a custom configuration directory..githubpage/site.json.Run GitHubPage: Open website preview to open the local website view. Saving a note rebuilds the preview but does not publish anything. To publish, open the cloud-upload ribbon action or Open publish panel, review the selected files, enter a commit message, and explicitly confirm the Git operation.
Direct pushes to the configured main branch are disabled by default. The recommended workflow creates an author/<name>/<task> branch, pushes it, and opens a pull request. The optional direct-main setting never uses force-push.
GitHubPage requires desktop capabilities because publishing a repository cannot be implemented entirely through the Obsidian Vault API.
git executable with an argument array and shell: false. It uses Git for status, branch, add, commit, fetch, fast-forward merge, push, and explicit abort operations. It does not execute repository-provided shell scripts.obsidian-githubpage-starter-vault.zip from this project's GitHub Releases. Opening a pull request launches a GitHub compare URL.127.0.0.1, uses an unguessable session URL, and renders inside a sandboxed iframe with a restrictive Content Security Policy.GitHub Pages websites are commonly public. Build exclusions such as draft: true are publishing controls, not a confidentiality boundary; do not commit secrets or private notes to a public repository.
GitHubPage 是一个桌面端 Obsidian 插件:既可以把整个 Vault 作为 GitHub Pages 仓库,也可以选择 Vault 内的一个文件夹作为独立仓库;用户以 Obsidian 原生方式编写,并在 Obsidian 中预览由线上部署使用的同一渲染核心、同一主题和同一精确版本生成的网站。
演示站源码位于 examples/starter-vault,根目录的 Pages Workflow 每次从 npm 安装精确版本 CLI,因此线上页面本身就是发布链路的端到端验证。
.githubpage/site.json 与 .githubpage/theme/ 配置、布局、CSS 和本地资源。127.0.0.1 的内存预览,使用随机会话 Cookie、CSP 和沙箱 iframe。main 后的 GitHub Pages 部署。main.js、manifest.json、styles.css,放入 Vault 的 .obsidian/plugins/github-page/,然后启用 GitHubPage。升级文件后重启 Obsidian,或禁用再重新启用插件。.githubpage/ 和 Pages Workflow。.githubpage/site.json 中的站点地址(只需首次配置)。插件升级时会自动迁移兼容的 engineVersion,不需要手动改 JSON。author/<作者>/<任务> 分支,发布后打开 GitHub PR。若仓库策略允许,也可在设置中启用 Allow direct main-branch push,直接发布到主分支。保存笔记、重建预览和发布远端是三个独立动作:保存只写入本地文件;自动重建只刷新 Obsidian 内预览;只有 Publish updates / Review and publish 才会操作 Git。主分支直推模式下,推送成功会触发 .github/workflows/pages.yml 并更新 GitHub Pages;协作分支模式下,需在发布面板打开 PR,并在合并到 main 后触发 Pages。
若发布时取消勾选了部分改动,插件只提交并推送选中的文件,同时保留其余本地改动;为避免拉取影响未提交内容,本次会安全跳过远端拉取。插件从不强推,远端已前进或出现冲突时会停止并提示处理。
左侧目录显示 Vault 中真实的文件夹和文件名,文件夹可按层级展开;点击目录栏的 −/+ 可以独立收起或恢复左右侧栏。右侧“本页目录”不显示序号,H2 为顶层,H3 向右缩进 1.25rem,H4 向右缩进 2.5rem,点击链接可跳转到标题锚点。超长行内公式和块公式都在公式容器内横向滚动,不会撑宽页面。
插件不会保存 GitHub Token。HTTPS 使用 Git Credential Manager/系统密钥环,SSH 使用现有密钥。所选位置必须正好是 Git 仓库根目录;插件会拒绝把普通子目录或上级仓库误当成当前站点仓库。
初始化命令只在所选仓库缺少 .githubpage/site.json 时执行,并且会在写入前检查所有目标文件;已有文件不会被覆盖。空仓库安装完整示例,已有内容的仓库只安装站点支持文件。它不会替用户创建 GitHub 仓库、配置 origin 或提交 Git,仓库创建和权限仍由 GitHub/Git 完成。
vault/
├── .github/workflows/pages.yml
├── .githubpage/
│ ├── site.json
│ └── theme/
│ ├── theme.json
│ ├── layout.html
│ ├── styles.css
│ └── assets/
├── Folder/
│ └── Note.md
└── index.md
Vault 内文件夹模式的结构如下,Vault 中仓库外的内容不会参与预览构建、Git 状态或发布:
vault/
├── .obsidian/
├── Private Notes/
└── Published Site/ ← 设置中的 Repository folder
├── .git/
├── .github/workflows/pages.yml
├── .githubpage/
└── index.md
site.json 的 engineVersion 必须与插件/CLI 精确一致。插件升级时会自动迁移 schema 兼容的版本;Pages Workflow 按该值临时安装 CLI,因此 Vault 不需要 package.json 或 package-lock.json。默认发布全部 Markdown;draft: true 或 publish: false 排除页面。排除只影响构建,敏感内容不得提交到 Git。
主题布局可以使用以下 Handlebars 插槽:head、runtime、siteTitle、pageTitle、language、basePath、navigation、breadcrumbs、tableOfContents、search、darkMode 和 content。主题不允许脚本、事件属性、外部资源、主动 SVG、meta refresh 或 CSS @import;交互来自内置运行时。
完整 JSON Schema 位于 schemas/site.schema.json 和 schemas/theme.schema.json。
obsidian-githubpage validate --root .
obsidian-githubpage build --root . --output _site
CLI 遇到配置、主题、歧义链接、失效 wikilink、失效 Markdown 链接、资源或数学公式错误时返回非零退出码。输出采用临时目录写完后替换,拒绝写入 Vault 根、.git、.obsidian 或 .githubpage。
npm install
npm run check
构建会在根目录生成 Obsidian 所需的 main.js,并生成独立的 CLI、核心和 Node 适配器产物。插件发布需包含 main.js、manifest.json 和 styles.css。
请阅读 SECURITY.md。GitHub Pages 网站通常是公开的,即使源仓库可见性不同,也不应把构建排除当作保密机制。