Main Sections
mainSections 参数用于过滤页面,默认为 ["posts", "docs"]。
1mainSections = ["blog", "posts", "docs", "notes"]
内容类型
你可能想在其他 Section 中使用 docs 布局,比如 /notes。这可以通过在 front matter 中设置 type = "docs" 实现。
文章原型
我们也可以为 notes 创建一个原型,让 Hugo 处理 type。
1$ cp themes/hugo-theme-bootstrap/archetypes/default.md archetypes/notes.md
然后在 archetypes/notes.md 中添加 type = "docs"。现在 hugo new notes/blah-blah-blah 将会复制 archetypes/notes.md 的内容到新的文章。
同样地,你也可以为 posts、docs 等自定义原型。
Sections 模板
你可能还想在 notes 中使用和 docs 一样的列表布局。
1{{ define "content" }}
2{{- partial "docs/nav" . -}}
3<div class="col-lg-7 ms-auto">
4 {{ partial "docs/list" . }}
5</div>
6{{- partial "docs/sidebar" . -}}
7{{ end }}
书写文章
假设默认语言为
en。
1$ hugo new posts/new-post/index.md
上述命令创建了一篇英文文章,同样的,我们也可以创建一篇简体中文的文章:
1$ hugo new posts/new-post/index.zh-cn.md
请注意:创建的文章一般处于草稿状态,本地预览时,
hugo server需要指定-D参数才能预览草稿文章。文章发布时,需要将draft改为false,或者直接移除draft参数。
Summary Selection Order
- If
post.excerpt = "description"anddescriptionis not empty, then it’ll be used. - Manual splitting via
<!–more–>. - If
summaryon front matter isn’t empty, thensummarywill be selected. - The text of content will be cut off by
post.excerptMaxLengthand formatted in plain text or HTML whenpost.plainifyExcerpt = true.
1[post]
2 # excerpt = "description"
3 # excerptMaxLength = 120
4 # copyright = false # Whether to display copyright section on each post.
5 # plainifyExcerpt = false # Format excerpt in HTML if false.
Thumbnail Selection Order
- The
imageson front matter are preferred. - Page images resources that match the filename’s patterns:
*feature*,*cover*and*thumbnail*. Such asposts/my-page/feature.png.
The page images resources will be resized to several smaller versions to suit the users devices for saving the bandwidth.
文章置顶
你可以通过在 front matter 设置 pinned 为 true 以置顶文章。
1+++
2title = "Pinned Post"
3pinned = true
4weight = 100
5+++
如果有多个置顶文章,那么将按照
weight进行降序排序。
站点配置
1pinnedPost = false # 关闭文章置顶功能
2pinnedPostCount = 2 # 首页显示的置顶文章的数目
Carousel
将文章于 carousel 显示。
1+++
2carousel = true
3+++
评论