Files
tplate/web/templates/xml/sitemap.tmpl

21 lines
1.0 KiB
Cheetah

{{- define "xml/sitemap" }}
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0" xmlns:news="https://www.google.com/schemas/sitemap-news/0.9" xmlns:image="https://www.google.com/schemas/sitemap-image/1.1" xmlns:video="https://www.google.com/schemas/sitemap-video/1.1">
<url><loc>{{ .Config.URL }}</loc></url>
{{- range .Posts -}}
{{ if and (not (and .FM.ParsedFlags.ExternalPost .FM.URL)) (or (not .FM.ParsedFlags.HidePost) .FM.ParsedFlags.ShowInRSSAndSitemap) }}
{{- $targetDate := "" -}}
{{ if .FM.Updated -}}
{{ $targetDate = "2006-01-02T15:04:05.000Z" | .FM.TimeUpdated.Format -}}
{{ else if .FM.Date -}}
{{ $targetDate = "2006-01-02T15:04:05.000Z" | .FM.TimeDate.Format -}}
{{- end }}
<url>
<loc>{{ print $.Config.URL .FM.URI }}</loc>
{{ if $targetDate }}<lastmod>{{ $targetDate }}</lastmod>{{ end }}
<priority>0.5</priority>
</url>
{{- end }}
{{- end }}
</urlset>
{{- end }}