From e75784930dca9e367019ce498fd15076a63edb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 21 Feb 2024 19:06:46 +0100 Subject: [PATCH] Sitemap should not use list.xml Fixes #12101 --- hugolib/sitemap_test.go | 25 +++++++++++++++++++++++++ output/layouts/layout.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index 6c2cbc557..1f869c000 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -123,3 +123,28 @@ func TestParseSitemap(t *testing.T) { t.Errorf("Got \n%v expected \n%v", result, expected) } } + +func TestSitemapShouldNotUseListXML(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +disableKinds = ["term", "taxonomy"] +[languages] +[languages.en] +weight = 1 +languageName = "English" +[languages.nn] +weight = 2 +-- layouts/_default/list.xml -- +Site: {{ .Site.Title }}| +-- layouts/home -- +Home. + +` + + b := Test(t, files) + + b.AssertFileContent("public/sitemap.xml", "https://example.com/en/sitemap.xml") +} diff --git a/output/layouts/layout.go b/output/layouts/layout.go index b903e09ea..09606dba1 100644 --- a/output/layouts/layout.go +++ b/output/layouts/layout.go @@ -50,7 +50,7 @@ type LayoutDescriptor struct { } func (d LayoutDescriptor) isList() bool { - return !d.RenderingHook && d.Kind != "page" && d.Kind != "404" + return !d.RenderingHook && d.Kind != "page" && d.Kind != "404" && d.Kind != "sitemap" && d.Kind != "sitemapindex" } // LayoutHandler calculates the layout template to use to render a given output type.