diff options
author | Jeremy Epstein <jazepstein@gmail.com> | 2021-02-07 04:30:09 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-06 18:30:09 +0100 |
commit | 4867cd1dea34ee53fb73cede2bcff4792e470104 (patch) | |
tree | 6918d1ac19bdd12e2defa30d45b33772b2ea104e /hugolib/sitemap_test.go | |
parent | 92c6c40419bdc13b8bb422a212d1d79240356651 (diff) |
tpl/embedded: Exclude pages without Permalink from sitemap
Diffstat (limited to 'hugolib/sitemap_test.go')
-rw-r--r-- | hugolib/sitemap_test.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index 7302f6e62..3fa6ab3ae 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -25,12 +25,14 @@ import ( const sitemapTemplate = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> {{ range .Data.Pages }} + {{- if .Permalink -}} <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 }} </url> + {{- end -}} {{ end }} </urlset>` @@ -80,6 +82,7 @@ func doTestSitemapOutput(t *testing.T, internal bool) { content := readDestination(th, th.Fs, outputSitemap) c.Assert(content, qt.Not(qt.Contains), "404") + c.Assert(content, qt.Not(qt.Contains), "<loc></loc>") } func TestParseSitemap(t *testing.T) { |