Hugo 站點地圖模板
Hugo 提供內置的站點地圖模板。
概述
Hugo 的嵌入式站點地圖模板符合 站點地圖協議 v0.9 版本。
對於單語言項目,Hugo 使用 嵌入式站點地圖模板 在 publishDir 的根目錄生成 sitemap.xml 文件。
對於多語言項目,Hugo 生成:
- 使用 嵌入式站點地圖模板 在每個站點(語言)的根目錄生成 sitemap.xml 文件
- 使用 嵌入式站點地圖索引模板 在
publishDir的根目錄生成 sitemap.xml 文件
配置
請參閱 配置站點地圖。
覆蓋默認值
在前沿中覆蓋給定頁面的默認值。
---
sitemap:
changefreq: weekly
disable: true
priority: 0.8
title: 新聞
---+++
title = '新聞'
[sitemap]
changefreq = 'weekly'
disable = true
priority = 0.8
+++{
"sitemap": {
"changefreq": "weekly",
"disable": true,
"priority": 0.8
},
"title": "新聞"
}
覆蓋內置模板
要覆蓋內置 sitemap.xml 模板,請創建新的 layouts/sitemap.xml 文件。當遍歷頁面集合時,分別使用 .Sitemap.ChangeFreq 和 .Sitemap.Priority 訪問 更改頻率 和 優先級。
要覆蓋內置 sitemapindex.xml 模板,請創建新的 layouts/sitemapindex.xml 文件。
禁用站點地圖生成
您可以在站點配置中禁用站點地圖生成:
disableKinds:
- sitemap
disableKinds = ['sitemap']
{
"disableKinds": [
"sitemap"
]
}