Skip to content

Commit

Permalink
Fix panic when cascading headless from site config to section that do…
Browse files Browse the repository at this point in the history
…es not have an _index.md file

Fixes gohugoio#12172
  • Loading branch information
bep committed Feb 28, 2024
1 parent 7cf6f84 commit e6f3be7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions hugolib/cascade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion hugolib/page__meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e6f3be7

Please sign in to comment.