Page

Keywords

返回前置元数据中定义的关键词切片。

签名
PAGE.Keywords
返回类型
[]string

默认情况下,Hugo 在创建相关内容集合时会用到关键词。

title = 'How to make spicy tuna hand rolls'
keywords = ['tuna','sriracha','nori','rice']

在模板中列出关键词:

{{ range .Keywords }}
  {{ . }}
{{ end }}

或者使用 delimit 函数:

{{ delimit .Keywords ", " ", and " }} → tuna, sriracha, nori, and rice

关键词也可以用作一种有用的分类法:

[taxonomies]
tag = 'tags'
keyword = 'keywords'
category = 'categories'