使用 Obsidian 统一管理多个博客项目(Vault + 软链接方案)
预计 5 min read
前言
在日常写博客的过程中,我逐渐维护了多个不同类型的博客项目。例如:
-
一个基于 Astro 的个人博客
-
一个自动化生成内容的博客项目
-
以及一些日常记录的 Markdown 笔记
这些内容分别分散在不同的项目目录中,例如:
1/Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog2/Volumes/SanXiaoXing/Blog/blog_auto/source/_posts3/Volumes/SanXiaoXing/Blog/Note虽然我使用 Obsidian 进行 Markdown 写作,但如果每个目录都单独作为一个 Vault 打开,不仅切换麻烦,也无法进行统一搜索和管理。
因此,需要一种方法:
-
可以 统一查看所有 Markdown 文档
-
又 不影响原有博客项目结构
-
同时 修改内容可以直接同步到项目中
最终选择的方案是:
建立一个统一的 Obsidian Vault,并使用 macOS 的软链接(Symbolic Link)映射各个博客目录。
原理说明
软链接(Symbolic Link)是一种文件系统机制,它允许在一个目录中创建一个“指向另一个目录”的链接。
在 Obsidian 中看起来像是普通文件夹,但实际上内容仍然在原始项目中。
因此可以实现:
-
Obsidian 统一管理
-
博客项目结构保持不变
-
Git 提交不受影响
目录规划
首先创建一个统一的 Obsidian Vault,例如:
1/Volumes/SanXiaoXing/Blog/ObsidianVault目标结构如下:
1ObsidianVault2 astro_blog3 hexo_blog4 notes其中:
| 文件夹 | 实际指向 |
|---|---|
| astro_blog | Astro 博客文章目录 |
| hexo_blog | Hexo 博客文章目录 |
| notes | 个人笔记 |
创建软链接
在 macOS 终端中执行以下操作。
进入 Vault 目录
1cd /Volumes/SanXiaoXing/Blog/ObsidianVault创建 Astro 博客映射
1ln -s /Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog astro_blog创建 Hexo 博客映射
1ln -s /Volumes/SanXiaoXing/Blog/blog_auto/source/_posts hexo_blog创建笔记映射
1ln -s /Volumes/SanXiaoXing/Blog/Note notes完成后的目录结构
执行
1ls -l可以看到:
1astro_blog -> /Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog2hexo_blog -> /Volumes/SanXiaoXing/Blog/blog_auto/source/_posts3notes -> /Volumes/SanXiaoXing/Blog/Note在 Obsidian 中显示为:
1ObsidianVault2 astro_blog3 hexo_blog4 notes现在就可以:
-
在一个 Vault 中管理所有博客
-
统一搜索所有文章
-
使用统一插件和模板
-
修改内容立即同步到项目
推荐优化
由于博客项目通常包含大量开发文件,例如:
-
node_modules -
.git -
dist -
.astro
这些文件对写作没有意义,但会影响 Obsidian 的扫描速度。
可以在 Obsidian 设置中排除这些目录:
1Settings → Files & Links → Excluded files添加:
1**/node_modules/**2**/.git/**3**/dist/**4**/.astro/**这样 Vault 会更加流畅。
进阶玩法
如果安装 Dataview 插件,还可以建立一个博客管理面板,例如显示最近修改的博客:
1TABLE file.mtime as 修改时间2FROM "astro_blog" OR "hexo_blog"3SORT file.mtime desc这样就可以在一个页面看到所有博客文章的更新情况。
总结
通过 统一 Vault + 软链接 的方式,可以很好地解决多博客项目管理的问题:
优点:
-
Markdown 写作环境统一
-
项目结构不被破坏
-
Git 工作流保持正常
-
支持跨博客全文搜索
-
维护成本极低
对于同时维护多个博客项目的人来说,这是一个非常高效且优雅的解决方案。
结语
工具的价值,在于减少无意义的操作,让注意力重新回到创作本身。
当写作环境足够顺手时,剩下的事情,就只是继续写下去。