summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-12-08 14:53:28 +0800
committerReorx <novoreorx@gmail.com>2022-12-08 14:53:28 +0800
commit345bea16cbe8c1da5bb38f6e1025f79c984c1544 (patch)
treee21d1281817be887e97d576a845cf2aa3ed1c22f
parent6f9714cf2b276dd47f6c18e827f5f5288875a471 (diff)
add custom sitemap to ignore nositemap pages
-rw-r--r--layouts/_default/sitemap.xml24
1 files changed, 24 insertions, 0 deletions
diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml
new file mode 100644
index 0000000..bafe215
--- /dev/null
+++ b/layouts/_default/sitemap.xml
@@ -0,0 +1,24 @@
+{{ 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 }}
+ {{- if and (not .Params.nositemap) .Permalink -}}
+ <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>
+ {{- end -}}
+ {{ end }}
+</urlset>