mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 14:40:43 +03:00
tpl: Fix when layout specified in front matter and no match is found
Fixes #13628
This commit is contained in:
parent
a88b488181
commit
1409d037b3
2 changed files with 26 additions and 1 deletions
|
@ -177,7 +177,7 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, oth
|
||||||
w.w2 = weight2Group1
|
w.w2 = weight2Group1
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.LayoutFromUser == "" && other.LayoutFromTemplate != "" && (other.LayoutFromTemplate == this.LayoutFromTemplate || other.LayoutFromTemplate == layoutAll) {
|
if other.LayoutFromTemplate != "" && (other.LayoutFromTemplate == this.LayoutFromTemplate || other.LayoutFromTemplate == layoutAll) {
|
||||||
w.w1 += weightLayoutStandard
|
w.w1 += weightLayoutStandard
|
||||||
w.w2 = weight2Group1
|
w.w2 = weight2Group1
|
||||||
|
|
||||||
|
|
|
@ -1204,3 +1204,28 @@ layouts/_partials/comment.ru.xml
|
||||||
b.AssertFileContent("public/ru/index.html", "layouts/_partials/comment.ru.html") // fail
|
b.AssertFileContent("public/ru/index.html", "layouts/_partials/comment.ru.html") // fail
|
||||||
b.AssertFileContent("public/ru/index.xml", "layouts/_partials/comment.ru.xml") // fail
|
b.AssertFileContent("public/ru/index.xml", "layouts/_partials/comment.ru.xml") // fail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLayoutIssue13628(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ['home','rss','sitemap','taxonomy','term']
|
||||||
|
-- content/p1.md --
|
||||||
|
---
|
||||||
|
title: p1
|
||||||
|
layout: foo
|
||||||
|
---
|
||||||
|
-- layouts/single.html --
|
||||||
|
layouts/single.html
|
||||||
|
-- layouts/list.html --
|
||||||
|
layouts/list.html
|
||||||
|
`
|
||||||
|
|
||||||
|
for range 5 {
|
||||||
|
|
||||||
|
b := hugolib.Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/p1/index.html", "layouts/single.html")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue