Sitemap should not use list.xml

Fixes #12101
This commit is contained in:
Bjørn Erik Pedersen 2024-02-21 19:06:46 +01:00
parent b8ab5c9be6
commit e75784930d
2 changed files with 26 additions and 1 deletions

View file

@ -123,3 +123,28 @@ func TestParseSitemap(t *testing.T) {
t.Errorf("Got \n%v expected \n%v", result, expected) 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")
}

View file

@ -50,7 +50,7 @@ type LayoutDescriptor struct {
} }
func (d LayoutDescriptor) isList() bool { 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. // LayoutHandler calculates the layout template to use to render a given output type.