@@ -21,7 +21,9 @@ import (
2121 "github.com/gohugoio/hugo/helpers"
2222)
2323
24- const baseFileBase = "baseof"
24+ const (
25+ baseFileBase = "baseof"
26+ )
2527
2628var (
2729 aceTemplateInnerMarkers = [][]byte {[]byte ("= content" )}
@@ -170,11 +172,14 @@ func CreateTemplateNames(d TemplateLookupDescriptor) (TemplateNames, error) {
170172 // For each of the steps above, it will first look in the project, then, if theme is set,
171173 // in the theme's layouts folder.
172174 // Also note that the <current-path> may be both the project's layout folder and the theme's.
173- pairsToCheck := [][]string {
174- {baseTemplatedDir , currBaseFilename },
175- {baseTemplatedDir , baseFilename },
176- {"_default" , currBaseFilename },
177- {"_default" , baseFilename },
175+ pairsToCheck := createPairsToCheck (baseTemplatedDir , baseFilename , currBaseFilename )
176+
177+ if strings .Contains (currBaseFilename , ".terms." ) {
178+ // We need to get from baseof.terms.html to baseof.html etc.
179+ // See #3856
180+ currBaseFilename = strings .Replace (currBaseFilename , ".terms" , "" , 1 )
181+ baseFilename = strings .Replace (baseFilename , ".terms" , "" , 1 )
182+ pairsToCheck = append (pairsToCheck , createPairsToCheck (baseTemplatedDir , baseFilename , currBaseFilename )... )
178183 }
179184
180185 Loop:
@@ -194,6 +199,15 @@ func CreateTemplateNames(d TemplateLookupDescriptor) (TemplateNames, error) {
194199
195200}
196201
202+ func createPairsToCheck (baseTemplatedDir , baseFilename , currBaseFilename string ) [][]string {
203+ return [][]string {
204+ {baseTemplatedDir , currBaseFilename },
205+ {baseTemplatedDir , baseFilename },
206+ {"_default" , currBaseFilename },
207+ {"_default" , baseFilename },
208+ }
209+ }
210+
197211func basePathsToCheck (path []string , layoutDir , workLayoutDir , themeLayoutDir string ) []string {
198212 // workLayoutDir will always be the most specific, so start there.
199213 pathsToCheck := []string {filepath .Join ((append ([]string {workLayoutDir }, path ... ))... )}
0 commit comments