diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml index 39dd94da0dff..9e01e7995d29 100644 --- a/layouts/_default/sitemap.xml +++ b/layouts/_default/sitemap.xml @@ -2,9 +2,15 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml"> {{ range .Data.Pages }} {{ if not (or .Params.private .Params.block_external_search_index .Params.redirect_to .Params.redirect_url (not (partial "taxonomy-indexable.html" .))) }} + {{ $lastmod := .Lastmod }} + {{ if in (slice "home" "section" "taxonomy" "term") .Kind }} + {{ range .RegularPagesRecursive }} + {{ if .Lastmod.After $lastmod }}{{ $lastmod = .Lastmod }}{{ end }} + {{ end }} + {{ end }} - {{ .Site.Params.canonicalURL }}{{ .RelPermalink }}{{ if not .Lastmod.IsZero }} - {{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }}{{ with .Sitemap.ChangeFreq }} + {{ .Site.Params.canonicalURL }}{{ .RelPermalink }}{{ 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 }}