]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Improve behavior of defaultContentLanguageInSubdir when only the default language...
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 13 Jul 2023 13:42:30 +0000 (15:42 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 13 Jul 2023 16:06:36 +0000 (18:06 +0200)
1 .Create sitemapindex in root of publishDir (will contain link to sitemap.xml in defaultContentLanguage site)
2. Create index.html in root of publishDir (will redirect to defaultContentLanguage site)

Fixes #11229

hugolib/config_test.go
hugolib/hugo_sites.go
hugolib/site_render.go

index cdac0fbab93dc89620512db7c67f0948ece3f3e2..100144ca14662a8b897fcb27c64f852c24833fba 100644 (file)
@@ -1321,6 +1321,9 @@ Home.
 
                b.AssertFileContent("public/en/index.html", "Home.")
                b.AssertFileContent("public/en/foo/bar.txt", "Foo.")
+               b.AssertFileContent("public/index.html", "refresh")
+               b.AssertFileContent("public/sitemap.xml", "sitemapindex")
+               b.AssertFileContent("public/en/sitemap.xml", "urlset")
        })
 
        t.Run("Two languages, default in sub dir", func(t *testing.T) {
@@ -1351,6 +1354,9 @@ Home.
 
                b.AssertFileContent("public/en/index.html", "Home.")
                b.AssertFileContent("public/en/foo/bar.txt", "Foo.")
+               b.AssertFileContent("public/index.html", "refresh")
+               b.AssertFileContent("public/sitemap.xml", "sitemapindex")
+               b.AssertFileContent("public/en/sitemap.xml", "urlset")
        })
 
        t.Run("Two languages, default in root", func(t *testing.T) {
@@ -1381,6 +1387,8 @@ Home.
 
                b.AssertFileContent("public/index.html", "Home.")
                b.AssertFileContent("public/foo/bar.txt", "Foo.")
+               b.AssertFileContent("public/sitemap.xml", "sitemapindex")
+               b.AssertFileContent("public/en/sitemap.xml", "urlset")
        })
 
 }
index 9c121f7ac1191ed4b8efe471a203c4145ae7ea39..de19a3669b16fbe841f606d42ef721051e728989 100644 (file)
@@ -437,7 +437,7 @@ func (cfg *BuildCfg) shouldRender(p *pageState) bool {
 }
 
 func (h *HugoSites) renderCrossSitesSitemap() error {
-       if !h.isMultiLingual() || h.Conf.IsMultihost() {
+       if h.Conf.IsMultihost() || !(h.Conf.DefaultContentLanguageInSubdir() || h.Conf.IsMultiLingual()) {
                return nil
        }
 
index c4c3f389ba8ef58fe202d18392d7269d9f34f901..f9c1dd498c49bf0a6ff9689ae46be2337664615a 100644 (file)
@@ -384,7 +384,7 @@ func (s *Site) renderAliases() error {
 // renderMainLanguageRedirect creates a redirect to the main language home,
 // depending on if it lives in sub folder (e.g. /en) or not.
 func (s *Site) renderMainLanguageRedirect() error {
-       if !s.h.isMultiLingual() || s.h.Conf.IsMultihost() {
+       if s.h.Conf.IsMultihost() || !(s.h.Conf.DefaultContentLanguageInSubdir() || s.h.Conf.IsMultiLingual()) {
                // No need for a redirect
                return nil
        }