Skip to content

Commit 088cd2f

Browse files
committed
tpl: Fix when layout specified in front matter and no match is found
Fixes #13628
1 parent a88b488 commit 088cd2f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: tpl/tplimpl/templatedescriptor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, oth
177177
w.w2 = weight2Group1
178178
}
179179

180-
if this.LayoutFromUser == "" && other.LayoutFromTemplate != "" && (other.LayoutFromTemplate == this.LayoutFromTemplate || other.LayoutFromTemplate == layoutAll) {
180+
if other.LayoutFromTemplate != "" && (other.LayoutFromTemplate == this.LayoutFromTemplate || other.LayoutFromTemplate == layoutAll) {
181181
w.w1 += weightLayoutStandard
182182
w.w2 = weight2Group1
183183

Diff for: tpl/tplimpl/templatestore_integration_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -1204,3 +1204,28 @@ layouts/_partials/comment.ru.xml
12041204
b.AssertFileContent("public/ru/index.html", "layouts/_partials/comment.ru.html") // fail
12051205
b.AssertFileContent("public/ru/index.xml", "layouts/_partials/comment.ru.xml") // fail
12061206
}
1207+
1208+
func TestLayoutIssue13628(t *testing.T) {
1209+
t.Parallel()
1210+
1211+
files := `
1212+
-- hugo.toml --
1213+
disableKinds = ['home','rss','sitemap','taxonomy','term']
1214+
-- content/p1.md --
1215+
---
1216+
title: p1
1217+
layout: foo
1218+
---
1219+
-- layouts/single.html --
1220+
layouts/single.html
1221+
-- layouts/list.html --
1222+
layouts/list.html
1223+
`
1224+
1225+
for range 5 {
1226+
1227+
b := hugolib.Test(t, files)
1228+
1229+
b.AssertFileContent("public/p1/index.html", "layouts/single.html")
1230+
}
1231+
}

0 commit comments

Comments
 (0)