Skip to content

Commit c19f1f2

Browse files
committed
tpl: Resolve layouts/all.html for all html output formats
Fixes #13587
1 parent 9221cbc commit c19f1f2

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Diff for: tpl/templates/templates_integration_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,23 @@ Home.
194194
b.AssertFileContent("public/index.html", "layouts/baseof.html")
195195
b.AssertFileContent("public/amp/index.html", "layouts/baseof.amp.html")
196196
}
197+
198+
func TestAllVsAmp(t *testing.T) {
199+
t.Parallel()
200+
201+
files := `
202+
-- hugo.toml --
203+
-- content/_index.md --
204+
---
205+
title: "Home"
206+
outputs: ["html", "amp"]
207+
---
208+
title: "Home"
209+
-- layouts/all.html --
210+
All.
211+
212+
`
213+
b := hugolib.Test(t, files)
214+
b.AssertFileContent("public/index.html", "All.")
215+
b.AssertFileContent("public/amp/index.html", "All.")
216+
}

Diff for: tpl/tplimpl/templatedescriptor.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
9292
if other.Kind != "" && other.Kind != this.Kind {
9393
return w
9494
}
95+
9596
if other.Layout != "" && other.Layout != layoutAll && other.Layout != this.Layout {
9697
if isLayoutCustom(this.Layout) {
9798
if this.Kind == "" {
@@ -108,6 +109,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
108109
return w
109110
}
110111
}
112+
111113
if other.Lang != "" && other.Lang != this.Lang {
112114
return w
113115
}
@@ -120,7 +122,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
120122
// We want e.g. home page in amp output format (media type text/html) to
121123
// find a template even if one isn't specified for that output format,
122124
// when one exist for the html output format (same media type).
123-
if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && this.Layout != other.Layout)) {
125+
if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && (this.Layout != other.Layout && other.Layout != layoutAll))) {
124126
return w
125127
}
126128

0 commit comments

Comments
 (0)