跳转到主内容
菜单

内容类型与模板查找

约 1 分钟 更新于 2026-10-05

什么是内容类型?

官方给出的回答:

Hugo assumes that the same structure that works to organize your source content is used to organize the rendered site.

简单翻译一下:Hugo 假设「用来组织源内容的结构」同样用来组织渲染出的站点1。

内容类型是一种组织内容的方式。

Hugo 从 front matter 的 type 字段中解析内容类型。

如果没有设置那么,类型就是第一个目录的目录名。

例如: 如果没有设置类型,content/blog/my-first-event.md 将是 blog 类型。

手动在 front matter 中设置类型

md
+++
title = " "
type = "blog"
+++

那么在模版中如果有 layout/blog/目录


  1. Hugo Documentation, Content organization. https://gohugo.io/content-management/organization/(访问 2026-10-04) ↩︎