diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go index 47e53d927..f3060814c 100644 --- a/hugolib/cascade_test.go +++ b/hugolib/cascade_test.go @@ -876,3 +876,44 @@ Background: {{ .Params.background }}| b.AssertFileContent("public/p1/index.html", "Background: yosemite.jpg") } } + +// Issue #12465. +func TestCascadeOverlap(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['home','rss','sitemap','taxonomy','term'] +-- layouts/_default/list.html -- +{{ .Title }} +-- layouts/_default/single.html -- +{{ .Title }} +-- content/s/_index.md -- +--- +title: s +cascade: + _build: + render: never +--- +-- content/s/p1.md -- +--- +title: p1 +--- +-- content/sx/_index.md -- +--- +title: sx +--- +-- content/sx/p2.md -- +--- +title: p2 +--- +` + + b := Test(t, files) + + b.AssertFileExists("public/s/index.html", false) + b.AssertFileExists("public/s/p1/index.html", false) + + b.AssertFileExists("public/sx/index.html", true) // failing + b.AssertFileExists("public/sx/p2/index.html", true) // failing +} diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 6927562f1..b930845e5 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -1397,7 +1397,7 @@ func (sa *sitePagesAssembler) applyAggregates() error { pw.WalkContext.Data().Insert(keyPage, cascade) } } else { - _, data := pw.WalkContext.Data().LongestPrefix(keyPage) + _, data := pw.WalkContext.Data().LongestPrefix(paths.Dir(keyPage)) if data != nil { cascade = data.(*maps.Ordered[page.PageMatcher, maps.Params]) }