diff --git a/hugo.yaml b/hugo.yaml index ee58b16..dc5bd8f 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -117,7 +117,7 @@ params: mainSections: ["post"] description: "A blog documenting my homelab journey, covering automation, self-hosted services, and hands-on experiments with open source technologies." favicon: "/favicon-32x32.png" - excludedFromSitemap: ["/tags/", "/categories/", "/search/"] + sitemapFilter: ["/tags/", "/categories/", "/search/"] sidebar: avatar: diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml index 2b98530..2dc959f 100644 --- a/layouts/_default/sitemap.xml +++ b/layouts/_default/sitemap.xml @@ -1,17 +1,30 @@ {{ printf "" | safeHTML }} - {{ range .Pages }} - {{ if not (in .Site.Params.excludedFromSitemap .Data.Plural) }} - - {{ .Permalink }} - {{ if not .Lastmod.IsZero }} - {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }} - {{ end }} - {{ with .Sitemap.ChangeFreq }} - {{ . }} - {{ end }} - - {{ end }} + {{ range $page := .Data.Pages }} + {{- $incldueURL := true -}} + {{- range $val := $.Site.Params.sitemapFilter -}} + {{- if (strings.Contains $page.Permalink $val ) -}} + {{- $incldueURL = false -}} + {{- end -}} + {{- end -}} + {{- if and .Permalink $incldueURL -}} + + {{ .Permalink }}{{ if not .Lastmod.IsZero }} + {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} + {{ . }}{{ end }}{{ if ge .Sitemap.Priority 0.0 }} + {{ .Sitemap.Priority }}{{ end }}{{ if .IsTranslated }}{{ range .Translations }} + {{ end }} + {{ end }} + + {{- end -}} {{ end }} \ No newline at end of file