Skip to content

Commit e757849

Browse files
committed
Sitemap should not use list.xml
Fixes gohugoio#12101
1 parent b8ab5c9 commit e757849

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

hugolib/sitemap_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,28 @@ func TestParseSitemap(t *testing.T) {
123123
t.Errorf("Got \n%v expected \n%v", result, expected)
124124
}
125125
}
126+
127+
func TestSitemapShouldNotUseListXML(t *testing.T) {
128+
t.Parallel()
129+
130+
files := `
131+
-- hugo.toml --
132+
baseURL = "https://example.com"
133+
disableKinds = ["term", "taxonomy"]
134+
[languages]
135+
[languages.en]
136+
weight = 1
137+
languageName = "English"
138+
[languages.nn]
139+
weight = 2
140+
-- layouts/_default/list.xml --
141+
Site: {{ .Site.Title }}|
142+
-- layouts/home --
143+
Home.
144+
145+
`
146+
147+
b := Test(t, files)
148+
149+
b.AssertFileContent("public/sitemap.xml", "https://example.com/en/sitemap.xml")
150+
}

output/layouts/layout.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type LayoutDescriptor struct {
5050
}
5151

5252
func (d LayoutDescriptor) isList() bool {
53-
return !d.RenderingHook && d.Kind != "page" && d.Kind != "404"
53+
return !d.RenderingHook && d.Kind != "page" && d.Kind != "404" && d.Kind != "sitemap" && d.Kind != "sitemapindex"
5454
}
5555

5656
// LayoutHandler calculates the layout template to use to render a given output type.

0 commit comments

Comments
 (0)