summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-07 09:07:12 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-07 09:50:50 +0100
commit7afac3f1adcdbaa7e93a7062dbd687ec5e58df9c (patch)
tree834f36a61aa64ebc3d23c2f57bdbb910492b7972
parenta4b17470a81e3c0ac71fd43aef2110336bfe6848 (diff)
Don't auto-create empty sections for nested taxonomies
Fixes #12188
-rw-r--r--hugolib/content_map_page.go8
-rw-r--r--hugolib/taxonomy_test.go34
2 files changed, 42 insertions, 0 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index f20a30abe..764078623 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -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] {
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index e8bf54758..bfdfd8dfd 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -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)
+}