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