HUGO
Menu
GitHub 87548 stars Mastodon

LinkTitle

返回给定页面的链接标题。

Syntax

PAGE.LinkTitle

Returns

string

LinkTitle 方法返回 front matter 中定义的 linkTitle 字段,回退到 Title 方法返回的值。

---
linkTitle: Dessert recipes
title: Seventeen delightful recipes for healthy desserts
---
+++
linkTitle = 'Dessert recipes'
title = 'Seventeen delightful recipes for healthy desserts'
+++
{
   "linkTitle": "Dessert recipes",
   "title": "Seventeen delightful recipes for healthy desserts"
}
{{ .LinkTitle }} → Dessert recipes

如上所示,当页面标题较长时,在 front matter 中定义链接标题是有利的。在模板中生成锚元素时使用它:

<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>

Last updated: January 1, 0001
Improve this page