{"id":"8781e61cdd7ae5a5","repo":"gohugoio/hugo","slug":"language-merge-not-supported-for-t","errorCode":null,"errorMessage":"language merge not supported for %T","messagePattern":"language merge not supported for %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/lang/lang.go","lineNumber":246,"sourceCode":"\n\treturn string(b), nil\n}\n\ntype pagesLanguageMerger interface {\n\tMergeByLanguageInterface(other any) (any, error)\n}\n\n// Merge creates a union of pages from two languages.\nfunc (ns *Namespace) Merge(p2, p1 any) (any, error) {\n\tif !hreflect.IsTruthful(p1) {\n\t\treturn p2, nil\n\t}\n\tif !hreflect.IsTruthful(p2) {\n\t\treturn p1, nil\n\t}\n\tmerger, ok := p1.(pagesLanguageMerger)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"language merge not supported for %T\", p1)\n\t}\n\treturn merger.MergeByLanguageInterface(p2)\n}\n","sourceCodeStart":228,"sourceCodeEnd":250,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/lang/lang.go#L228-L250","documentation":"`lang.Merge` unions page collections across languages by requiring the first collection (p1) to implement Hugo's internal `pagesLanguageMerger` interface (`MergeByLanguageInterface`). Only Hugo Pages collections implement it; if p1 is any other type (a plain slice, map, string, etc.), Hugo returns this error with the offending type.","triggerScenarios":"Calling `{{ $pages | lang.Merge $other }}` where the second (pipeline) argument is not a Hugo Pages collection — e.g. a `slice`, the result of `where` that produced a generic slice, a map, or a single Page. Note both arguments are checked for truthiness first, so an empty p1 skips the check.","commonSituations":"Multilingual sites where a template passes `.Site.Data` values, a plain `slice`, or a single `.Page` instead of `.Site.RegularPages`/`.Translations`-derived page collections; applying `lang.Merge` to results of `collections` functions that returned `[]interface{}` instead of Pages.","solutions":["Ensure both arguments are Pages collections, e.g. `{{ $merged := site.RegularPages | lang.Merge ((index site.Sites 1).RegularPages) }}`.","If filtering first, use `where` directly on a Pages collection (which preserves the Pages type) rather than building a new slice with `slice`/`append` of mixed values.","For non-page data, use `collections.Merge` or `append`/`union` instead — `lang.Merge` is only for pages across languages."],"exampleFix":"<!-- before -->\n{{ $merged := (slice $p1 $p2) | lang.Merge $frPages }}\n<!-- after -->\n{{ $merged := site.RegularPages | lang.Merge $frSite.RegularPages }}","handlingStrategy":"type-guard","validationCode":"{{ $v := site.Params.someMap }}\n{{ if reflect.IsMap $v }}{{/* safe to merge language params */}}{{ end }}","typeGuard":"{{ $isMergeable := reflect.IsMap $v }}","tryCatchPattern":"{{ with try (merge $base $override) }}{{ with .Err }}{{ warnf \"language merge failed: %s\" . }}{{ else }}{{ .Value }}{{ end }}{{ end }}","preventionTips":["Only maps (params objects) can be merged across languages — check with reflect.IsMap first","Keep the same param structure (map vs slice vs scalar) for a given key across all language configs","Don't mix scalar and map values under the same params key in different language files"],"tags":["hugo","templates","multilingual","pages"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}