sitemap-template.md (2945B)
1 ---
2 title: Sitemap Templates
3 description: Hugo provides built-in sitemap templates.
4 date: 2017-02-01
5 categories: [templates]
6 keywords: [sitemap, xml, templates]
7 menu:
8 docs:
9 parent: "templates"
10 weight: 160
11 weight: 160
12 sections_weight: 160
13 draft: false
14 aliases: [/layout/sitemap/,/templates/sitemap/]
15 toc: true
16 ---
17
18 ## Overview
19
20 Hugo's built-in sitemap templates conform to v0.9 of the [sitemap protocol].
21
22 With a monolingual project, Hugo generates a sitemap.xml file in the root of the [`publishDir`] using the built-in [sitemap.xml] template.
23
24 With a multilingual project, Hugo generates:
25
26 - A sitemap.xml file in the root of each site (language) using the built-in [sitemap.xml] template
27 - A sitemap.xml file in the root of the [`publishDir`] using the built-in [sitemapindex.xml] template
28
29 ## Configuration
30
31 Set the default values for [change frequency] and [priority], and the name of the generated file, in your site configuration.
32
33 {{< code-toggle file="config" >}}
34 [sitemap]
35 changefreq = 'monthly'
36 filename = 'sitemap.xml'
37 priority = 0.5
38 {{</ code-toggle >}}
39
40 changefreq
41 : 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).
42
43 filename
44 : The name of the generated file. Default is `sitemap.xml`.
45
46 priority
47 : 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).
48
49 ## Override Default Values
50
51 Override the default values for a given page in front matter.
52
53 {{< code-toggle file="news.md" fm=true >}}
54 title = 'News'
55 [sitemap]
56 changefreq = 'weekly'
57 priority = 0.8
58 {{</ code-toggle >}}
59
60 ## Override Built-in Templates
61
62 To override the built-in sitemap.xml template, create a new file in either of these locations:
63
64 - layouts/sitemap.xml
65 - layouts/_default/sitemap.xml
66
67 When ranging through the page collection, access the _change frequency_ and _priority_ with `.Sitemap.ChangeFreq` and `.Sitemap.Priority` respectively.
68
69 To override the built-in sitemapindex.xml template, create a new file in either of these locations:
70
71 - layouts/sitemapindex.xml
72 - layouts/_default/sitemapindex.xml
73
74 ## Disable Sitemap Generation
75
76 You may disable sitemap generation in your site configuration:
77
78 {{< code-toggle file="config" >}}
79 disableKinds = ['sitemap']
80 {{</ code-toggle >}}
81
82 [`publishDir`]: {{< relref "getting-started/configuration#publishdir" >}}
83 [change frequency]: <https://www.sitemaps.org/protocol.html#changefreqdef>
84 [priority]: <https://www.sitemaps.org/protocol.html#priority>
85 [sitemap protocol]: <https://www.sitemaps.org/protocol.html>
86 [sitemap.xml]: <https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/sitemap.xml>
87 [sitemapindex.xml]: <https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/sitemapindex.xml>