HUGO
Menu
GitHub 87548 stars Mastodon

Name

返回給定菜單項的 name 屬性。

Syntax

MENUENTRY.Name

Returns

string

如果您是 自動 定義菜單項,Name 方法返回頁面的 LinkTitle,回退到其 Title

如果您是 在 front matter 中在站點配置中 定義菜單項,Name 方法返回給定菜單項的 name 屬性。如果未定義 name,並且菜單項解析為頁面,則 Name 返回頁面的 LinkTitle,回退到其 Title

<ul>
  {{ range .Site.Menus.main }}
    <li><a href="{{ .URL }}">{{ .Name }}</a></li>
  {{ end }}
</ul>

Last updated: January 1, 0001
Improve this page