HUGO
Menu
GitHub 87548 stars Mastodon

Weight

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

Syntax

MENUENTRY.Weight

Returns

int

如果您是 自動 定義菜單項,Weight 方法返回頁面的 Weight

如果您是 在 front matter 中在站點配置中 定義菜單項,Weight 方法返回 weight 屬性,回退到頁面的 Weight

在此虛構示例中,我們根據權重限制菜單項數量:

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

Last updated: January 1, 0001
Improve this page