使用相对路径插入图片

hugo new posts/my-new-post/index.md

将文章创建成一个文件夹,文章的源文件就是这个 index.md,在这个文件加下我们可以新建一个 asserts目录,用来存放附件(如图片),然后再 index.md中就可以通过相对路径的方式引用这个文件了。

文件夹结构
│  index.md
│
└─asserts
        fantasy-3077928.jpg
		
在index中插入图片:
![](asserts/fantasy-3077928.jpg)

Hugo PaperMod 主题中给文章添加封面图片:

在文章源markdown文件的前言区添加如下配置

---
cover:
  image: "asserts/fantasy-3077928.jpg"
---

调试

可以使用 Go 语言的 printf 函数调试 Hugo 模板,参考Template Debugging

{{ printf "%#v" site.Params.mainSections }}

主要部分自定义

site.Params.mainSections 可以用来指定网站主要内容部分的部分列表

params:
  mainSections: ["posts", "blog"]