HUGO
Menu
GitHub 87548 stars Mastodon

Hugo 站點地圖模板

Hugo 提供內置的站點地圖模板。

概述

Hugo 的嵌入式站點地圖模板符合 站點地圖協議 v0.9 版本。

對於單語言項目,Hugo 使用 嵌入式站點地圖模板publishDir 的根目錄生成 sitemap.xml 文件。

對於多語言項目,Hugo 生成:

配置

請參閱 配置站點地圖

覆蓋默認值

在前沿中覆蓋給定頁面的默認值。

---
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"
   ]
}

Last updated: January 1, 0001
Improve this page