]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Don't auto-create empty sections for nested taxonomies
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 08:07:12 +0000 (09:07 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 08:50:50 +0000 (09:50 +0100)
Fixes #12188

hugolib/content_map_page.go
hugolib/taxonomy_test.go

index f20a30abeaead49ce8eb3d629d3820e996318044..7640786236856dbdf56c3e12f20e64ee71235d0f 100644 (file)
@@ -1814,6 +1814,14 @@ func (sa *sitePagesAssembler) addMissingRootSections() error {
                                return false, nil
                        }
 
+                       switch ps.Kind() {
+                       case kinds.KindPage, kinds.KindSection:
+                               // OK
+                       default:
+                               // Skip taxonomy nodes etc.
+                               return false, nil
+                       }
+
                        p := ps.m.pathInfo
                        section := p.Section()
                        if section == "" || seen[section] {
index e8bf547589d9c229ec2fe8bc0b44bdf1a6b36723..bfdfd8dfdc2a2009d732a7657a9d404cc444e8e4 100644 (file)
@@ -936,3 +936,37 @@ title: Authors Page
        b.AssertFileExists("public/authors/index.html", true)
        b.AssertFileContent("public/authors/index.html", "layouts/_default/author.terms.html") // failing test
 }
+
+func TestTaxonomyNestedEmptySectionsIssue12188(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['rss','sitemap']
+defaultContentLanguage = 'en'
+defaultContentLanguageInSubdir = true
+[languages.en]
+weight = 1
+[languages.ja]
+weight = 2
+[taxonomies]
+'s1/category' = 's1/category'
+-- layouts/_default/single.html --
+{{ .Title }}|
+-- layouts/_default/list.html --
+{{ .Title }}|
+-- content/s1/p1.en.md --
+---
+title: p1
+---
+`
+
+       b := Test(t, files)
+
+       b.AssertFileExists("public/en/s1/index.html", true)
+       b.AssertFileExists("public/en/s1/p1/index.html", true)
+       b.AssertFileExists("public/en/s1/category/index.html", true)
+
+       b.AssertFileExists("public/ja/s1/index.html", false) // failing test
+       b.AssertFileExists("public/ja/s1/category/index.html", true)
+}