Skip to content

Commit 5e62cc6

Browse files
committed
tpl: Fix layout fall back logic when layout is set in front matter but not found
Fixes #13630
1 parent 1408c15 commit 5e62cc6

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎tpl/tplimpl/templatedescriptor.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,10 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, oth
9494
}
9595

9696
if other.LayoutFromTemplate != "" && other.LayoutFromTemplate != layoutAll {
97-
if this.LayoutFromUser == "" {
97+
if this.LayoutFromUser == "" || this.LayoutFromUser != other.LayoutFromTemplate {
9898
if other.LayoutFromTemplate != this.LayoutFromTemplate {
9999
return w
100100
}
101-
} else if isLayoutStandard(this.LayoutFromUser) {
102-
if other.LayoutFromTemplate != this.LayoutFromUser {
103-
return w
104-
}
105101
}
106102
}
107103

‎tpl/tplimpl/templatestore_integration_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,3 +1245,28 @@ p: {{ partial "p.html" . }}
12451245
b.Assert(err, qt.IsNotNil)
12461246
b.Assert(err.Error(), qt.Contains, "error calling partial: maximum template call stack size exceeded")
12471247
}
1248+
1249+
func TestIssue13630(t *testing.T) {
1250+
t.Parallel()
1251+
1252+
files := `
1253+
-- hugo.toml --
1254+
disableKinds = ['rss','sitemap']
1255+
-- content/p1.md --
1256+
---
1257+
title: p1
1258+
layout: foo
1259+
---
1260+
-- layouts/list.html --
1261+
layouts/list.html
1262+
-- layouts/taxononmy.html.html --
1263+
layouts/taxononmy.html.html
1264+
`
1265+
1266+
var b *hugolib.IntegrationTestBuilder
1267+
1268+
for range 3 {
1269+
b = hugolib.Test(t, files)
1270+
b.AssertFileExists("public/p1/index.html", false)
1271+
}
1272+
}

0 commit comments

Comments
 (0)