From: Daniel Lang Date: Tue, 3 Jan 2017 16:11:22 +0000 (-0800) Subject: Update documentation and test for sitemap template X-Git-Tag: v0.19~135 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2127203ae386da117647f619299a0a53b71b3c4d;p=brevno-suite%2Fhugo Update documentation and test for sitemap template --- diff --git a/docs/content/templates/sitemap.md b/docs/content/templates/sitemap.md index 10cfeefb..1ecbfb3b 100644 --- a/docs/content/templates/sitemap.md +++ b/docs/content/templates/sitemap.md @@ -37,8 +37,8 @@ Protocol](http://www.sitemaps.org/protocol.html). {{ range .Data.Pages }} - {{ .Permalink }} - {{ safeHTML ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}{{ with .Sitemap.ChangeFreq }} + {{ .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 }} diff --git a/examples/blog/layouts/sitemap.xml b/examples/blog/layouts/sitemap.xml index 8eb623b8..00582425 100644 --- a/examples/blog/layouts/sitemap.xml +++ b/examples/blog/layouts/sitemap.xml @@ -1,8 +1,8 @@ {{ range .Data.Pages }} - {{ .Permalink }} - {{ safeHTML ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}{{ with .Sitemap.ChangeFreq }} + {{ .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 }} diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index aba47ae7..3fb26638 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -26,8 +26,8 @@ import ( const sitemapTemplate = ` {{ range .Data.Pages }} - {{ .Permalink }} - {{ safeHTML ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}{{ with .Sitemap.ChangeFreq }} + {{ .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 }}