tpl/tplimpl: Make template name lookup case-insensitive

Closes #15057

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Joe Mooring
2026-06-23 09:24:27 -07:00
committed by Bjørn Erik Pedersen
parent 790a8aa474
commit e46d37a984
3 changed files with 100 additions and 1 deletions
+5 -1
View File
@@ -14,6 +14,8 @@
package tplimpl
import (
"strings"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/hugolib/sitesmatrix"
"github.com/gohugoio/hugo/resources/kinds"
@@ -44,6 +46,8 @@ type TemplateDescriptor struct {
}
func (d *TemplateDescriptor) normalizeFromFile() {
d.LayoutFromTemplate = strings.ToLower(d.LayoutFromTemplate)
if d.LayoutFromTemplate == d.OutputFormat {
d.LayoutFromTemplate = ""
}
@@ -138,7 +142,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
// when one exist for the html output format (same media type).
skip := category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && (this.LayoutFromTemplate != other.LayoutFromTemplate && other.LayoutFromTemplate != layoutAll)))
if this.LayoutFromUser != "" {
skip = skip && (this.LayoutFromUser != other.LayoutFromTemplate)
skip = skip && this.LayoutFromUser != other.LayoutFromTemplate
}
if skip {
return w
+1
View File
@@ -425,6 +425,7 @@ func (q *TemplateQuery) init() {
}
q.Name = strings.ToLower(q.Name)
q.Desc.LayoutFromUser = strings.ToLower(q.Desc.LayoutFromUser)
if q.Category == 0 {
panic("category not set")