aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-02-28 18:33:42 +0100
committerBjørn Erik Pedersen <[email protected]>2024-02-28 19:26:55 +0100
commitfce8d82b79335394ee9102f5bb449d76a81f808f (patch)
tree375faa083231cc1cce1fcd0dd18a60650caa0b07
parent4a502f7eb475afa35849b3dcf312daf3e3832d51 (diff)
downloadhugo-fce8d82b79335394ee9102f5bb449d76a81f808f.tar.gz
hugo-fce8d82b79335394ee9102f5bb449d76a81f808f.zip
Fix panic when cascading headless from site config to section that does not have an _index.md file
Fixes #12172
-rw-r--r--hugolib/cascade_test.go26
-rw-r--r--hugolib/page__meta.go2
2 files changed, 27 insertions, 1 deletions
diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go
index b9b80a3a1..8075f190f 100644
--- a/hugolib/cascade_test.go
+++ b/hugolib/cascade_test.go
@@ -766,3 +766,29 @@ path = '/p1.md'
b := Test(t, files)
b.AssertLogNotContains(`looks like a path with an extension`)
}
+
+func TestCascadeIssue12172(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['rss','sitemap','taxonomy','term']
+[[cascade]]
+headless = true
+[cascade._target]
+path = '/s1**'
+-- content/s1/p1.md --
+---
+title: p1
+---
+-- layouts/_default/single.html --
+{{ .Title }}|
+-- layouts/_default/list.html --
+{{ .Title }}|
+ `
+ b := Test(t, files)
+
+ b.AssertFileExists("public/index.html", true)
+ b.AssertFileExists("public/s1/index.html", false)
+ b.AssertFileExists("public/s1/p1/index.html", false)
+}
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go
index 082e3145a..8c148923d 100644
--- a/hugolib/page__meta.go
+++ b/hugolib/page__meta.go
@@ -523,7 +523,7 @@ params:
// pages.
isHeadless := cast.ToBool(v)
params[loki] = isHeadless
- if p.File().TranslationBaseName() == "index" && isHeadless {
+ if isHeadless {
pm.pageConfig.Build.List = pagemeta.Never
pm.pageConfig.Build.Render = pagemeta.Never
}