跳过正文
  1. Teches/
  2. 前端/
  3. Hugo/

hugo学习250723

·71 字
目录

hugo工作流程
#

  1. url route -> 确定页面类型

hugo页面类型推断
#

(1) 文件系统结构
#

Hugo 会扫描 content/ 目录下的内容文件(如 .md 或 .html),根据文件的位置和命名规则自动推断页面类型:

</> text
1_index.md → 列表页(kind: "section" 或 kind: "home")
2
3普通内容文件(如 post.md) → 单页(kind: "page" 或 kind: "single")
4
5分类/标签页 → 分类列表(kind: "taxonomy" 或 kind: "term")

(2) 页面 Front Matter
#

通过 Front Matter 中的 type 或 layout 字段可手动指定类型(覆盖自动推断):

</> yaml
1type: "posts"  # 强制指定为 posts 类型的单页
2layout: "custom-list"  # 使用自定义模板