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

  1. Only call lang.Merge on Hugo Pages collections.
  2. For custom slices or maps, build the union manually in the template or Go code.
  3. 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

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


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)