Skip to content

Commit

Permalink
Sitemap should not use list.xml
Browse files Browse the repository at this point in the history
Fixes #12101
  • Loading branch information
bep committed Feb 21, 2024
1 parent b8ab5c9 commit e757849
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions hugolib/sitemap_test.go
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion output/layouts/layout.go
Expand Up @@ -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.
Expand Down

0 comments on commit e757849

Please sign in to comment.