2019-10-21 04:22:28 -04:00
---
2023-07-29 05:15:54 -04:00
title: Sitemap templates
2022-04-08 07:32:01 -04:00
description: Hugo provides built-in sitemap templates.
2019-10-21 04:22:28 -04:00
categories: [templates]
keywords: [sitemap, xml, templates]
menu:
docs:
2023-05-22 10:43:12 -04:00
parent: templates
2023-07-29 05:15:54 -04:00
weight: 170
weight: 170
2019-10-21 04:22:28 -04:00
aliases: [/layout/sitemap/,/templates/sitemap/]
2022-04-08 07:32:01 -04:00
toc: true
2019-10-21 04:22:28 -04:00
---
2022-04-08 07:32:01 -04:00
## Overview
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
Hugo's built-in sitemap templates conform to v0.9 of the [sitemap protocol].
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
With a monolingual project, Hugo generates a sitemap.xml file in the root of the [`publishDir`] using the built-in [sitemap.xml] template.
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
With a multilingual project, Hugo generates:
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
- A sitemap.xml file in the root of each site (language) using the built-in [sitemap.xml] template
- A sitemap.xml file in the root of the [`publishDir`] using the built-in [sitemapindex.xml] template
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
## Configuration
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
Set the default values for [change frequency] and [priority], and the name of the generated file, in your site configuration.
2019-10-21 04:22:28 -04:00
2023-05-27 10:59:59 -04:00
{{< code-toggle file = "hugo" > }}
2022-04-08 07:32:01 -04:00
[sitemap]
changefreq = 'monthly'
filename = 'sitemap.xml'
priority = 0.5
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
changefreq
: How frequently a page is likely to change. Valid values are `always` , `hourly` , `daily` , `weekly` , `monthly` , `yearly` , and `never` . Default is `""` (change frequency omitted from rendered sitemap).
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
filename
: The name of the generated file. Default is `sitemap.xml` .
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
priority
: The priority of a page relative to any other page on the site. Valid values range from 0.0 to 1.0. Default is `-1` (priority omitted from rendered sitemap).
2019-10-21 04:22:28 -04:00
2023-07-29 05:15:54 -04:00
## Override default values
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
Override the default values for a given page in front matter.
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
{{< code-toggle file = "news.md" fm = true > }}
title = 'News'
[sitemap]
changefreq = 'weekly'
priority = 0.8
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-07-29 05:15:54 -04:00
## Override built-in templates
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
To override the built-in sitemap.xml template, create a new file in either of these locations:
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
- layouts/sitemap.xml
- layouts/_default/sitemap.xml
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
When ranging through the page collection, access the _change frequency_ and _priority_ with `.Sitemap.ChangeFreq` and `.Sitemap.Priority` respectively.
To override the built-in sitemapindex.xml template, create a new file in either of these locations:
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
- layouts/sitemapindex.xml
- layouts/_default/sitemapindex.xml
2019-10-21 04:22:28 -04:00
2023-07-29 05:15:54 -04:00
## Disable sitemap generation
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
You may disable sitemap generation in your site configuration:
2023-05-27 10:59:59 -04:00
{{< code-toggle file = "hugo" > }}
2022-04-08 07:32:01 -04:00
disableKinds = ['sitemap']
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
[`publishDir`]: /getting-started/configuration#publishdir
2022-04-08 07:32:01 -04:00
[change frequency]: < https: / / www . sitemaps . org / protocol . html # changefreqdef >
[priority]: < https: / / www . sitemaps . org / protocol . html # priority >
[sitemap protocol]: < https: / / www . sitemaps . org / protocol . html >
[sitemap.xml]: < https: / / github . com / gohugoio / hugo / blob / master / tpl / tplimpl / embedded / templates / _default / sitemap . xml >
[sitemapindex.xml]: < https: / / github . com / gohugoio / hugo / blob / master / tpl / tplimpl / embedded / templates / _default / sitemapindex . xml >