HUGO
Menu
GitHub 87548 stars Mastodon

Keywords

返回 front matter 中定义的关键词切片。

Syntax

PAGE.Keywords

Returns

[]string

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

---
keywords:
- tuna
- sriracha
- nori
- rice
title: How to make spicy tuna hand rolls
---
+++
keywords = ['tuna', 'sriracha', 'nori', 'rice']
title = 'How to make spicy tuna hand rolls'
+++
{
   "keywords": [
      "tuna",
      "sriracha",
      "nori",
      "rice"
   ],
   "title": "How to make spicy tuna hand rolls"
}

在模板中列出关键词:

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

或使用 delimit 函数:

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

关键词也是一个有用的 分类法

taxonomies:
  category: categories
  keyword: keywords
  tag: tags
[taxonomies]
  category = 'categories'
  keyword = 'keywords'
  tag = 'tags'
{
   "taxonomies": {
      "category": "categories",
      "keyword": "keywords",
      "tag": "tags"
   }
}

Last updated: January 1, 0001
Improve this page