Params

在以下的前端:

content/news/annual-conference.md.
     
date: 2023-10-17T15:11:37-07:00
params:
  author:
    email: jsmith@example.org
    name: John Smith
  display_related: true
title: Annual conference
date = 2023-10-17T15:11:37-07:00
title = 'Annual conference'
[params]
  display_related = true
  [params.author]
    email = 'jsmith@example.org'
    name = 'John Smith'
{
   "date": "2023-10-17T15:11:37-07:00",
   "params": {
      "author": {
         "email": "jsmith@example.org",
         "name": "John Smith"
      },
      "display_related": true
   },
   "title": "Annual conference"
}

titledate 是標準參數,而其他欄位則是用戶自定義的。

可以通過[鏈接]這些[標識符]來訪問自定義參數:

{{ .Params.display_related }} → true
{{ .Params.author.name }} → John Smith

在上面的模板示例中,每個鍵都是有效的標識符。例如,這些鍵不包含短橫線。如果要訪問一個不是有效標識符的鍵,請使用 index 函數:

{{ index .Params "key-with-hyphens" }} → 2023