tpl: Fix when layout specified in front matter and no match is found - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 088cd2f996bfbbdf4ed01cafa2c8101b3ea0e94e
(DIR) parent a88b488181279befd50e1d127f9f67604f2f9854
(HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 20 Apr 2025 10:59:40 +0200
tpl: Fix when layout specified in front matter and no match is found
Fixes #13628
Diffstat:
M tpl/tplimpl/templatedescriptor.go | 2 +-
M tpl/tplimpl/templatestore_integrat… | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/tpl/tplimpl/templatedescriptor.go b/tpl/tplimpl/templatedescriptor.go
@@ -177,7 +177,7 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, oth
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.w2 = weight2Group1
(DIR) diff --git a/tpl/tplimpl/templatestore_integration_test.go b/tpl/tplimpl/templatestore_integration_test.go
@@ -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.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")
+ }
+}