Hugo 页面包
是什么
页面包(Page Bundles)是一个包含 index.md 的目录。Hugo 把这个目录当作一个页面,目录里的所有资源(图片、附件)可以用相对路径引用。
两种类型
- Leaf bundle:目录下有
index.md,不能再嵌套其他 bundle - Branch bundle:目录下有
_index.md(列表页),可以嵌套
文章是 leaf bundle,章节(如 /posts/、/notes/)是 branch bundle。
长什么样
content/
└── posts/
├── _index.md
├── hugo-deploy/
│ ├── index.md
│ ├── cover.webp
│ └── diagram.svg
└── obsidian-sync/
├── index.md
└── screenshot.png
引用方式
 <!-- 相对路径 -->

不需要 static/images/... 这种长路径。
为什么没全用
- 文章多时
content/posts/下会多一层目录,URL 变长(/posts/hugo-deploy/vs/posts/hugo-deploy.html) - 旧文章(没有 bundle 的)混在一起会显得乱
所以我在这里用的方案是混合:新写的文章用 bundle(带图时),纯文字的用单文件 .md。
评论