使用 Obsidian 统一管理多个博客项目(Vault + 软链接方案)

|
#obsidian #mac
最后更新于


预计 5 min read


前言

在日常写博客的过程中,我逐渐维护了多个不同类型的博客项目。例如:

  • 一个基于 Astro 的个人博客

  • 一个自动化生成内容的博客项目

  • 以及一些日常记录的 Markdown 笔记

这些内容分别分散在不同的项目目录中,例如:

1
/Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog
2
/Volumes/SanXiaoXing/Blog/blog_auto/source/_posts
3
/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

目标结构如下:

1
ObsidianVault
2
astro_blog
3
hexo_blog
4
notes

其中:

文件夹实际指向
astro_blogAstro 博客文章目录
hexo_blogHexo 博客文章目录
notes个人笔记

创建软链接

在 macOS 终端中执行以下操作。

进入 Vault 目录

1
cd /Volumes/SanXiaoXing/Blog/ObsidianVault

创建 Astro 博客映射

1
ln -s /Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog astro_blog

创建 Hexo 博客映射

1
ln -s /Volumes/SanXiaoXing/Blog/blog_auto/source/_posts hexo_blog

创建笔记映射

1
ln -s /Volumes/SanXiaoXing/Blog/Note notes

完成后的目录结构

执行

1
ls -l

可以看到:

1
astro_blog -> /Volumes/SanXiaoXing/Blog/Astro_profile/src/content/blog
2
hexo_blog -> /Volumes/SanXiaoXing/Blog/blog_auto/source/_posts
3
notes -> /Volumes/SanXiaoXing/Blog/Note

在 Obsidian 中显示为:

1
ObsidianVault
2
astro_blog
3
hexo_blog
4
notes

现在就可以:

  • 在一个 Vault 中管理所有博客

  • 统一搜索所有文章

  • 使用统一插件和模板

  • 修改内容立即同步到项目


推荐优化

由于博客项目通常包含大量开发文件,例如:

  • node_modules

  • .git

  • dist

  • .astro

这些文件对写作没有意义,但会影响 Obsidian 的扫描速度。

可以在 Obsidian 设置中排除这些目录:

1
Settings → Files & Links → Excluded files

添加:

1
**/node_modules/**
2
**/.git/**
3
**/dist/**
4
**/.astro/**

这样 Vault 会更加流畅。


进阶玩法

如果安装 Dataview 插件,还可以建立一个博客管理面板,例如显示最近修改的博客:

1
TABLE file.mtime as 修改时间
2
FROM "astro_blog" OR "hexo_blog"
3
SORT file.mtime desc

这样就可以在一个页面看到所有博客文章的更新情况。


总结

通过 统一 Vault + 软链接 的方式,可以很好地解决多博客项目管理的问题:

优点:

  • Markdown 写作环境统一

  • 项目结构不被破坏

  • Git 工作流保持正常

  • 支持跨博客全文搜索

  • 维护成本极低

对于同时维护多个博客项目的人来说,这是一个非常高效且优雅的解决方案。


结语

工具的价值,在于减少无意义的操作,让注意力重新回到创作本身。

当写作环境足够顺手时,剩下的事情,就只是继续写下去。