Main Sections
The mainSections
parameter is used to filter pages, default to ["posts", "docs"]
.
1mainSections = ["blog", "posts", "docs", "notes"]
Content Types
You may want to use docs
layout in other sections instead of /docs
, such as /notes
.
It’s easy to do that by setting type = "docs"
on the front matter.
Archetypes
We can also create a archetype for notes
, let’s Hugo take care of the type
.
1$ cp themes/hugo-theme-bootstrap/archetypes/default.md archetypes/notes.md
And the append type = "docs"
on the front matter of archetypes/notes.md
. Now, hugo new notes/blah-blah-blah
will copy the content of archetypes/notes.md
to your new notes.
Similarly, you can also custom the archetypes for posts
, docs
and so on.
Sections Template
You may also want to use the same list layout of docs
on notes
.
1{{ define "content" }}
2{{- partial "docs/catalog" . -}}
3<div class="col-lg-7 ms-auto">
4 {{ partial "docs/list" . }}
5</div>
6{{- partial "docs/sidebar" . -}}
7{{ end }}
Write New Articles
Suppose the default language is
en
.
1$ hugo new posts/new-post/index.md
The command above create a new post written in English. Similarly, we can create a post written in Simplified Chinese:
1$ hugo new posts/new-post/index.zh-cn.md
Please remind that, the created posts are generally in draft state. You’ll need to specify the
-D
parameter of the commandhugo server
for previewing. Similarly, you need to change thedraft
tofalse
or removedraft
parameter if you want to publish the article.
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.
Pinning Posts
You can pin posts on the home page by setting pinned
to true
on the front matter.
1+++
2title = "Pinned Post"
3pinned = true
4weight = 100
5+++
If there is multiple pinned posts, they are sorted by
weight
in descending order.
1pinnedPost = false # Disable pinned posts globally.
2pinnedPostCount = 2 # The number of pinned posts shown on home page.
Carousel
Showing posts on carousel.
1+++
2carousel = true
3+++
Comments