From 9dfa9e70e6ac56cfbb875caf5fed412eb2b22d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 1 Mar 2024 11:37:53 +0100 Subject: Make sure that sitemaps gets generated even if there is a content bundle with the same path Fixes #12183 --- hugolib/content_map_page.go | 6 +++--- hugolib/sitemap_test.go | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 5388426c9..ddc22bb66 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -1764,7 +1764,7 @@ func (sa *sitePagesAssembler) addStandalonePages() error { if s.conf.EnableRobotsTXT { if m.i == 0 || s.Conf.IsMultihost() { - addStandalone("/robots", kinds.KindRobotsTXT, output.RobotsTxtFormat) + addStandalone("/_robots", kinds.KindRobotsTXT, output.RobotsTxtFormat) } } @@ -1777,11 +1777,11 @@ func (sa *sitePagesAssembler) addStandalonePages() error { } if sitemapEnabled { - addStandalone("/sitemap", kinds.KindSitemap, output.SitemapFormat) + addStandalone("/_sitemap", kinds.KindSitemap, output.SitemapFormat) skipSitemapIndex := s.Conf.IsMultihost() || !(s.Conf.DefaultContentLanguageInSubdir() || s.Conf.IsMultiLingual()) if !skipSitemapIndex { - addStandalone("/sitemapindex", kinds.KindSitemapIndex, output.SitemapIndexFormat) + addStandalone("/_sitemapindex", kinds.KindSitemapIndex, output.SitemapIndexFormat) } } diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index 1f869c000..6dad39fe3 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -148,3 +148,25 @@ Home. b.AssertFileContent("public/sitemap.xml", "https://example.com/en/sitemap.xml") } + +func TestSitemapAndContentBundleNamedSitemap(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['home','rss','section','taxonomy','term'] +-- layouts/_default/single.html -- +layouts/_default/single.html +-- layouts/sitemap/single.html -- +layouts/sitemap/single.html +-- content/sitemap/index.md -- +--- +title: My sitemap +type: sitemap +--- +` + + b := Test(t, files) + + b.AssertFileExists("public/sitemap.xml", true) +} -- cgit v1.2.3