2019-10-21 04:22:28 -04:00
---
2022-04-08 07:32:01 -04:00
title: Sitemap Templates
description: Hugo provides built-in sitemap templates.
2019-10-21 04:22:28 -04:00
date: 2017-02-01
categories: [templates]
keywords: [sitemap, xml, templates]
menu:
docs:
parent: "templates"
weight: 160
weight: 160
sections_weight: 160
draft: false
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
2022-04-08 07:32:01 -04:00
{{< code-toggle file = "config" > }}
[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
2022-04-08 07:32:01 -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
2022-04-08 07:32:01 -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
2022-04-08 07:32:01 -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:
{{< code-toggle file = "config" > }}
disableKinds = ['sitemap']
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2022-04-08 07:32:01 -04:00
[`publishDir`]: {{< relref " getting-started / configuration # publishdir " > }}
[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 >