个人网站与知识库搭建

个人网站与知识库搭建

本文记录 linbo.lol 个人服务入口和 note.linbo.lol 知识库的实际架构、发布流程与恢复方法。它取代旧的 Digital Garden 插件发布说明和 Vercel 私有 submodule 方案。

当前站点

地址 用途 承载方式
linbo.lol 个人服务导航 VPS 上的 Nginx
note.linbo.lol Obsidian 公开知识库 GitHub + Vercel

linbo.lol 目前统一提供以下入口:

网络和代理部分单独记录在 Tailscale + Clash + VPS 中继方案。

知识库架构

Obsidian Vault
    │
    │ Obsidian Git / git push
    ▼
Yu-Linbo/obsidian_backup          私有、完整、唯一数据源
    │
    │ GitHub Actions
    │ 筛选公开目录、转换双链、复制附件
    ▼
Yu-Linbo/obsidian_note            网站代码与公开内容
    │
    │ Vercel 自动构建
    ▼
https://note.linbo.lol/

两个仓库职责必须保持清晰:

发布范围

现在不再依赖 Digital Garden 插件,也不需要 dg-publish property。

默认发布仓库内的所有 Markdown,但以下目录始终排除:

self/**
ud_work/**
所有隐藏目录,例如 .obsidian/**、.trash/**、.github/**

因此:

Properties 约定

大部分笔记不需要 properties。文件路径会自动生成网页 URL,一级标题会作为页面标题。

只有确实需要时才添加:

---
title: 页面显示名称
permalink: /稳定的网页地址/
tags:
  - topic
status: evergreen
updated: 2026-09-08
---

建议:

首页固定使用仓库根目录的 Welcome.md,无需额外 property。

自动发布流程

当 obsidian_backup/master 收到提交时,.github/workflows/publish-digital-garden.yml 会执行:

  1. 检出 backup;
  2. 使用 GARDEN_REPO_TOKEN 检出 obsidian_note/main;
  3. 安装网站锁定的 Node.js 依赖;
  4. 执行 scripts/export-digital-garden.cjs;
  5. 清理 note 中旧的受管笔记和附件;
  6. 导出公开 Markdown、Obsidian 双链和图片;
  7. 检查重复 permalink;
  8. 以 github-actions[bot] 提交到 note;
  9. Vercel 检测到新提交后自动部署。

如果内容没有变化,Action 不会创建空提交。

GitHub Token

跨仓库推送使用 fine-grained personal access token:

Token 不得写入 Vault、.env、脚本或普通 Git 文件。到期后生成新 Token,并更新同名 Secret 即可。

本地验证

网站仓库首次使用前安装依赖:

cd ../obsidian_note
npm ci

从 backup 导出到本地网站仓库:

cd ../first_test
node scripts/export-digital-garden.cjs ../obsidian_note

构建网站:

cd ../obsidian_note
npm run build

导出命令会清理目标仓库中的旧笔记内容。执行前应确认 obsidian_note/src/site/notes 和 src/site/img/user 没有需要保留的手工修改。网页模板、组件和样式不在清理范围内。

域名与部署职责

推荐保持当前边界:

DNS 或 Vercel 配置变更后,应依次验证:

curl -I https://linbo.lol/
curl -I https://note.linbo.lol/

恢复与排障

更换电脑或恢复 Vault

  1. clone obsidian_backup;
  2. 用 Obsidian 打开仓库目录;
  3. 安装或启用 Obsidian Git;
  4. 不需要安装 Digital Garden 插件;
  5. 正常提交到 master 即可触发网站发布。

Action 无法检出或推送 note

检查:

Vercel 没有部署

先检查 obsidian_note/main 是否出现 Publish notes from obsidian_backup ... 提交:

私有 submodule

当前方案不再使用私有 Git submodule,也不需要在 Vercel Build Command 中拼接 GitHub Token。若将来重新引入私有 submodule,应优先使用只读 deploy key 或权限受限的 Token,避免 classic PAT 的整个 repo 权限。

日常维护

git pull
# 在 Obsidian 中编辑
git add .
git commit -m "vault backup: YYYY-MM-DD HH:mm:ss"
git push

推送后检查链路:

  1. backup 的 Publish Notes Website Action 成功;
  2. note 出现机器人提交;
  3. Vercel Production Deployment 成功;
  4. 首页、搜索、新页面和至少一个图片附件可访问。