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-tw.md
請注意:創建的文章一般處於草稿狀態,本地預覽時,
hugo server
需要指定-D
參數才能預覽草稿文章。文章發佈時,需要將draft
改為false
,或者直接移除draft
參數。
Summary Selection Order#
- If
post.excerpt = "description"
anddescription
is not empty, then it’ll be used. - Manual splitting via
<!–more–>
. - If
summary
on front matter isn’t empty, thensummary
will be selected. - The text of content will be cut off by
post.excerptMaxLength
and 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
images
on 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+++
作者#
HBS supports the authors taxonomy. Firstly, you’ll need to enable it by setting the following configuration.
1[taxonomies]
2 author = 'authors'
1taxonomies:
2 author: authors
1{
2 "taxonomies": {
3 "author": "authors"
4 }
5}
And then define the authors
on your posts.
1+++
2authors = [
3 "Foo",
4 "Bar"
5]
6+++
Now, the authors will be present on the post meta and sidebar taxonomies.
Finally, we may need to introduce the author in more detail. Take the Foo
as an example, just create a page with the following content and save it as /content/authors/foo/index.md
.
1---
2title: Razon Yang
3description: Gopher, PHPer, Full Stack Engineer.
4social:
5 github: razonyang
6 twitter: razonyang
7---
title
: The author display name.description
: The introduction.social
: Social links.
The author image should be placed at the same folder with pattern avatar*
, such as /content/authors/foo/avatar.png
.
評論