gohugoio/hugo · error
language merge not supported for %T
Error message
language merge not supported for %T
What it means
lang.Merge requires the second argument (p1) to implement the pagesLanguageMerger interface (a Hugo Pages method, MergeByLanguageInterface). Any type that does not satisfy that interface is rejected. See lang.go:244-247.
Solutions
- Only call lang.Merge on Hugo Pages collections.
- For custom slices or maps, build the union manually in the template or Go code.
- Ensure the second argument is the Pages object returned by a page lookup (.Pages, .RegularPages, etc.).
Example fix
// before
{{ lang.Merge $mySlice $otherSlice }}
// after
{{ lang.Merge .Pages $defaultPages }} Defensive patterns
Strategy: type-guard
Validate before calling
// Verify the value can be merged before calling lang.Merge.
type pagesLanguageMerger interface { MergeByLanguageInterface(other any) (any, error) }
if _, ok := p1.(pagesLanguageMerger); !ok {
return fmt.Errorf("type %T cannot be language-merged", p1)
} Type guard
func isPagesLanguageMerger(v any) bool {
_, ok := v.(interface{ MergeByLanguageInterface(any) (any, error) })
return ok
} Prevention
- Only merge Hugo Pages collections, not arbitrary slices or maps.
- Build custom unions manually for non-Pages data.
When it happens
Trigger: {{ lang.Merge $sliceA $sliceB }} where the second value is a plain slice, map, or custom collection rather than a Hugo Pages object.
Common situations: Attempting to merge arbitrary slices or maps; passing a regular page instead of a Pages collection; refactoring that changed the value type.
Related errors
- destination must be a map, got %T
- source must be a map, got %T
- wrong number of arguments, expecting at most 2, got
- arguments must be slices or arrays
- arguments to complement must be slices or arrays
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/8781e61cdd7ae5a5.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/lang/lang.go:246
return string(b), nil
}
type pagesLanguageMerger interface {
MergeByLanguageInterface(other any) (any, error)
}
// Merge creates a union of pages from two languages.
func (ns *Namespace) Merge(p2, p1 any) (any, error) {
if !hreflect.IsTruthful(p1) {
return p2, nil
}
if !hreflect.IsTruthful(p2) {
return p1, nil
}
merger, ok := p1.(pagesLanguageMerger)
if !ok {
return nil, fmt.Errorf("language merge not supported for %T", p1)
}
return merger.MergeByLanguageInterface(p2)
}
View on GitHub (pinned to 52c9bd7908)