diff options
Diffstat (limited to 'themes/default/layouts/_default/sitemap.xml')
-rw-r--r-- | themes/default/layouts/_default/sitemap.xml | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/themes/default/layouts/_default/sitemap.xml b/themes/default/layouts/_default/sitemap.xml index 63f5119..b751f65 100644 --- a/themes/default/layouts/_default/sitemap.xml +++ b/themes/default/layouts/_default/sitemap.xml @@ -1,22 +1,50 @@ -{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} -<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" - xmlns:xhtml="http://www.w3.org/1999/xhtml"> - {{ range .Data.Pages }} - <url> - <loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} - <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} - <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} - <priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - </url> +{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} +{{ printf `<?xml-stylesheet href="/sitemap.xsl" type="text/xsl"?>` | safeHTML }} + +{{- $changefreq := "weekly" -}} +{{- $priority := 0.5 -}} +{{- $lastmod := now.Format "2006-01-02T15:04:05-07:00" }} + +<urlset + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + xmlns:xhtml="http://www.w3.org/1999/xhtml" +> + {{- $notExpired := where .Data.Pages "Params.expirydate" "eq" nil -}} + {{- $notUnlisted := where .Data.Pages "Params.unlisted" "eq" nil -}} + {{- $filteredPages := $notExpired | intersect $notUnlisted -}} + {{- range $filteredPages }} + + {{- with .Sitemap.ChangeFreq -}} + {{- $changefreq = . -}} + {{- end -}} + + {{- if ge .Sitemap.Priority 0.0 -}} + {{- $priority = .Sitemap.Priority -}} + {{- end -}} + + {{- if not .Lastmod.IsZero -}} + {{- $lastmod = safeHTML (.Lastmod.Format "2006-01-02T15:04:05-07:00") -}} + {{- end }} + + <url> + <loc>{{ .Permalink }}</loc> + <lastmod>{{ $lastmod }}</lastmod> + <changefreq>{{ $changefreq }}</changefreq> + <priority>{{ $priority }}</priority> + {{- if .IsTranslated -}} + {{ range .Translations }} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{- end -}} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{ end }} + </url> {{ end }} </urlset> |