hugo 教学

7. Front Matter

  1. front matter is a kind of metadata

  2. three different language: yaml, toml, json

  3. build customer front matter

8. Archetypes

  1. 在 archetypes 下创建 default.md 来给所有默认新建的 content 赋予默认 front matter 内容
---
title: '{{ replace .File.ContentBaseName "-" " " | title }}'
date: {{ .Date }}
draft: false
author: "dayday"
---
  1. 在 archetypes 的各种目录(例如 posts)下创建 posts.md 来给 content/posts 下的内容赋予默认 front matter 内容

9. Shortcodes

10. Taxonomies

11. Template Basics

12. List Page Templates

13. Single Page Templates

14. Home Page Templates

layout 目录下的 index.html 管理的是 home page

15. Section Templates

layouts 下新建 posts/single.html

16. Base Templates & Blocks

17. Variables

18. Functions

可以查看 hugo func doc 获取更多内容

19. If Statements

19.1 How?

{{ $var1 := 1 }}
{{ $var2 := 2 }}

{{ if gt $var1 $var2 }}
    True
{{ else }}
    False
{{ end }}

如果有 and/or

{{ $var1 := 1 }}
{{ $var2 := 2 }}
{{ $var3 := 3 }}

{{ if and (lt $var1 $var2) (lt $var1 $var3) }}
    True
{{ else }}
    False
{{ end }}

19.2 常用操作符

eq
gt
ge
lt
le
not

20. Data Files

21. Partial Templates

21.1 如何定义

定义在 layouts/partials 目录下,例如 header.html

21.2 如何引用

在需要引用的页面中 {{ partials "header" . }},其中 . 代表了该 partial 和该页面拥有同样的作用域(可以引用 .Title 等等的变量)

22. Shortcode

22.1 collapse shortcode demo

展示一个可折叠的内容

summary 变量展示在折叠的 summary

openDefault 为默认折叠与否

Collapse Shortcode
  1. xxx
  2. yyy

22.2 rawhtml shortcode demo

rawhtml

还可以这么用?

rawhtml