summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-11 10:54:19 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-04-11 18:23:51 +0200
commitc19f1f2363fe96cfa8b6e4a5b9e5d75886bcff8b (patch)
tree3c0ddf397e2175121a42a372b77832966c953c5d
parent9221cbca496752fb1d06d664871e3d4532f473f5 (diff)
downloadhugo-c19f1f2363fe96cfa8b6e4a5b9e5d75886bcff8b.tar.gz
hugo-c19f1f2363fe96cfa8b6e4a5b9e5d75886bcff8b.zip
tpl: Resolve layouts/all.html for all html output formats
Fixes #13587
-rw-r--r--tpl/templates/templates_integration_test.go20
-rw-r--r--tpl/tplimpl/templatedescriptor.go4
2 files changed, 23 insertions, 1 deletions
diff --git a/tpl/templates/templates_integration_test.go b/tpl/templates/templates_integration_test.go
index 752709593..4150ec367 100644
--- a/tpl/templates/templates_integration_test.go
+++ b/tpl/templates/templates_integration_test.go
@@ -194,3 +194,23 @@ Home.
b.AssertFileContent("public/index.html", "layouts/baseof.html")
b.AssertFileContent("public/amp/index.html", "layouts/baseof.amp.html")
}
+
+func TestAllVsAmp(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+-- content/_index.md --
+---
+title: "Home"
+outputs: ["html", "amp"]
+---
+title: "Home"
+-- layouts/all.html --
+All.
+
+`
+ b := hugolib.Test(t, files)
+ b.AssertFileContent("public/index.html", "All.")
+ b.AssertFileContent("public/amp/index.html", "All.")
+}
diff --git a/tpl/tplimpl/templatedescriptor.go b/tpl/tplimpl/templatedescriptor.go
index 21649b032..fc757126f 100644
--- a/tpl/tplimpl/templatedescriptor.go
+++ b/tpl/tplimpl/templatedescriptor.go
@@ -92,6 +92,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
if other.Kind != "" && other.Kind != this.Kind {
return w
}
+
if other.Layout != "" && other.Layout != layoutAll && other.Layout != this.Layout {
if isLayoutCustom(this.Layout) {
if this.Kind == "" {
@@ -108,6 +109,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
return w
}
}
+
if other.Lang != "" && other.Lang != this.Lang {
return w
}
@@ -120,7 +122,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
// We want e.g. home page in amp output format (media type text/html) to
// find a template even if one isn't specified for that output format,
// when one exist for the html output format (same media type).
- if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && this.Layout != other.Layout)) {
+ if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && (this.Layout != other.Layout && other.Layout != layoutAll))) {
return w
}