summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-20 10:59:40 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-20 12:55:18 +0200
commit088cd2f996bfbbdf4ed01cafa2c8101b3ea0e94e (patch)
tree5ed21f08e24a65a0782735ec18593f5119fab8ec
parenta88b488181279befd50e1d127f9f67604f2f9854 (diff)
downloadhugo-088cd2f996bfbbdf4ed01cafa2c8101b3ea0e94e.tar.gz
hugo-088cd2f996bfbbdf4ed01cafa2c8101b3ea0e94e.zip
tpl: Fix when layout specified in front matter and no match is found
Fixes #13628
-rw-r--r--tpl/tplimpl/templatedescriptor.go2
-rw-r--r--tpl/tplimpl/templatestore_integration_test.go25
2 files changed, 26 insertions, 1 deletions
diff --git a/tpl/tplimpl/templatedescriptor.go b/tpl/tplimpl/templatedescriptor.go
index 8e4390fae..ca73c9f78 100644
--- 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
diff --git a/tpl/tplimpl/templatestore_integration_test.go b/tpl/tplimpl/templatestore_integration_test.go
index 32e1248fe..e59dad33a 100644
--- 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")
+ }
+}