HUGO
Menu
GitHub 87548 stars Mastodon

ByParam

返回給定頁面集合按給定參數升序排序。

Syntax

PAGES.ByParam PARAM

Returns

page.Pages

如果 front matter 中不存在給定參數,Hugo 將使用站點配置中匹配的參數(如果存在)。

{{ range .Pages.ByParam "author" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}

要按降序排序:

{{ range (.Pages.ByParam "author").Reverse }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}

如果目標參數是嵌套的,請使用點表示法訪問字段:

{{ range .Pages.ByParam "author.last_name" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}

Last updated: January 1, 0001
Improve this page