File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -1133,12 +1133,21 @@ func (s *TemplateStore) insertTemplate2(
1133
1133
tree .Insert (key , m )
1134
1134
}
1135
1135
1136
- if ! replace {
1137
- if v , found := m [nk ]; found {
1138
- if len (pi .Identifiers ()) >= len (v .PathInfo .Identifiers ()) {
1139
- // e.g. /pages/home.foo.html and /pages/home.html where foo may be a valid language name in another site.
1140
- return nil , nil
1141
- }
1136
+ nkExisting , existingFound := m [nk ]
1137
+ if ! replace && existingFound && fi != nil && nkExisting .Fi != nil {
1138
+ // See issue #13715.
1139
+ // We do the merge on the file system level, but from Hugo v0.146.0 we have a situation where
1140
+ // the project may well have a different layouts layout compared to the theme(s) it uses.
1141
+ // We could possibly have fixed that on a lower (file system) level, but since this is just
1142
+ // a temporary situation (until all projects are updated),
1143
+ // do a replace here if the file comes from higher up in the module chain.
1144
+ replace = fi .Meta ().ModuleOrdinal < nkExisting .Fi .Meta ().ModuleOrdinal
1145
+ }
1146
+
1147
+ if ! replace && existingFound {
1148
+ if len (pi .Identifiers ()) >= len (nkExisting .PathInfo .Identifiers ()) {
1149
+ // e.g. /pages/home.foo.html and /pages/home.html where foo may be a valid language name in another site.
1150
+ return nil , nil
1142
1151
}
1143
1152
}
1144
1153
Original file line number Diff line number Diff line change @@ -1103,6 +1103,23 @@ All.
1103
1103
b .AssertLogContains ("unrecognized render hook" )
1104
1104
}
1105
1105
1106
+ func TestLayoutOverrideThemeWhenThemeOnOldFormatIssue13715 (t * testing.T ) {
1107
+ t .Parallel ()
1108
+
1109
+ files := `
1110
+ -- hugo.toml --
1111
+ theme = "mytheme"
1112
+ -- layouts/list.html --
1113
+ layouts/list.html
1114
+ -- themes/mytheme/layouts/_default/list.html --
1115
+ mytheme/layouts/_default/list.html
1116
+
1117
+ `
1118
+
1119
+ b := hugolib .Test (t , files )
1120
+ b .AssertFileContent ("public/index.html" , "layouts/list.html" )
1121
+ }
1122
+
1106
1123
func BenchmarkExecuteWithContext (b * testing.B ) {
1107
1124
files := `
1108
1125
-- hugo.toml --
You can’t perform that action at this time.
0 commit comments