HUGO
Menu
GitHub 87548 stars Mastodon

Home

返回給定站點的主頁頁面對象。

Syntax

SITE.Home

Returns

page.Page

Site 對象上的 Home 方法是訪問主頁的便捷方式,功能上等同於:

{{ .Site.GetPage "/" }}

因為它返回 Page 對象,您可以通過 鏈接 使用任何可用的 頁面方法。例如:

{{ .Site.Home.Store.Set "greeting" "Hello" }}

此方法通常用於生成指向主頁的鏈接。例如:

站點配置:

baseURL: https://example.org/docs/
baseURL = 'https://example.org/docs/'
{
   "baseURL": "https://example.org/docs/"
}

模板:

{{ .Site.Home.Permalink }} → https://example.org/docs/ 
{{ .Site.Home.RelPermalink }} → /docs/

Last updated: January 1, 0001
Improve this page