Sitemap.md - hugo - [fork] hugo port for 9front
(HTM) git clone https://git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
Sitemap.md (2301B)
---
1 ---
2 title: Sitemap
3 description: Returns the sitemap settings for the given page as defined in front matter, falling back to the sitemap settings as defined in the site configuration.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: config.SitemapConfig
9 signatures: [PAGE.Sitemap]
10 ---
11
12 Access to the `Sitemap` method on a `Page` object is restricted to [sitemap templates].
13
14 ## Methods
15
16 ### ChangeFreq
17
18 (`string`) How frequently a page is likely to change. Valid values are `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`, and `never`. With the default value of `""` Hugo will omit this field from the sitemap. See [details](https://www.sitemaps.org/protocol.html#changefreqdef).
19
20 ```go-html-template
21 {{ .Sitemap.ChangeFreq }}
22 ```
23
24 ### Disable
25
26 {{< new-in 0.125.0 />}}
27
28 (`bool`) Whether to disable page inclusion. Default is `false`. Set to `true` in front matter to exclude the page.
29
30 ```go-html-template
31 {{ .Sitemap.Disable }}
32 ```
33
34 ### Priority
35
36 (`float`) The priority of a page relative to any other page on the site. Valid values range from 0.0 to 1.0. With the default value of `-1` Hugo will omit this field from the sitemap. See [details](https://www.sitemaps.org/protocol.html#prioritydef).
37
38 ```go-html-template
39 {{ .Sitemap.Priority }}
40 ```
41
42 ## Example
43
44 With this site configuration:
45
46 {{< code-toggle file=hugo >}}
47 [sitemap]
48 changeFreq = 'monthly'
49 {{< /code-toggle >}}
50
51 And this content:
52
53 {{< code-toggle file=content/news.md fm=true >}}
54 title = 'News'
55 [sitemap]
56 changeFreq = 'hourly'
57 {{< /code-toggle >}}
58
59 And this simplistic sitemap template:
60
61 ```xml {file="layouts/sitemap.xml"}
62 {{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
63 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
64 xmlns:xhtml="http://www.w3.org/1999/xhtml">
65 {{ range .Pages }}
66 <url>
67 <loc>{{ .Permalink }}</loc>
68 {{ if not .Lastmod.IsZero }}
69 <lastmod>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</lastmod>
70 {{ end }}
71 {{ with .Sitemap.ChangeFreq }}
72 <changefreq>{{ . }}</changefreq>
73 {{ end }}
74 </url>
75 {{ end }}
76 </urlset>
77 ```
78
79 The change frequency will be `hourly` for the news page, and `monthly` for other pages.
80
81 [sitemap templates]: /templates/sitemap/