fix: change sitemap format
All checks were successful
Blog Deployment / check-rebuild (push) Successful in 4s
Blog Deployment / build (push) Has been skipped
Blog Deployment / deploy-staging (push) Successful in 8s
Blog Deployment / test-staging (push) Successful in 2s
Blog Deployment / merge (push) Successful in 6s
Blog Deployment / deploy-production (push) Successful in 9s
Blog Deployment / test-production (push) Successful in 2s
Blog Deployment / clean (push) Has been skipped

This commit is contained in:
Vezpi 2025-06-05 07:25:32 +00:00
parent 805d834063
commit c12e1dcf7f
2 changed files with 26 additions and 13 deletions

View File

@ -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:

View File

@ -1,17 +1,30 @@
{{ 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 .Pages }}
{{ if not (in .Site.Params.excludedFromSitemap .Data.Plural) }}
<url>
<loc>{{ .Permalink }}</loc>
{{ if not .Lastmod.IsZero }}
<lastmod>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</lastmod>
{{ end }}
{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>
{{ end }}
</url>
{{ 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 -}}
<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>