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