Identifier
返回给定菜单条目的 `identifier` 属性。
Identifier 方法返回菜单条目的 identifier 属性。如果自动定义菜单条目,它返回该页面所属的 section(内容区块)。
[[menus.main]]
identifier = 'about'
name = 'About'
pageRef = '/about'
weight = 10
[[menus.main]]
identifier = 'contact'
name = 'Contact'
pageRef = '/contact'
weight = 20下面的示例在多语言项目中查询翻译表时使用了 Identifier 方法,若翻译表中不存在匹配的键,则回退到 name 属性:
<ul>
{{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ or (T .Identifier) .Name }}</a></li>
{{ end }}
</ul>