{"record":{"id":"1476a0e7df8a367b","repo":"gohugoio/hugo","slug":"t-cannot-be-merged-by-language-1476a0","errorCode":null,"errorMessage":"%T cannot be merged by language","messagePattern":"%T cannot be merged by language","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/resource/resources.go","lineNumber":264,"sourceCode":"\t}\n\n\tfor _, rr := range r2 {\n\t\tif translated, ok := rr.(translatedResource); ok {\n\t\t\tif _, found := m[translated.TranslationKey()]; !found {\n\t\t\t\tresult = append(result, rr)\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}\n\n// MergeByLanguageInterface is the generic version of MergeByLanguage. It\n// is here just so it can be called from the tpl package.\n// This is for internal use.\nfunc (r Resources) MergeByLanguageInterface(in any) (any, error) {\n\tr2, ok := in.(Resources)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%T cannot be merged by language\", in)\n\t}\n\treturn r.MergeByLanguage(r2), nil\n}\n\n// Source is an internal template and not meant for use in the templates. It\n// may change without notice.\ntype Source interface {\n\tPublish() error\n}\n\ntype ResourceGetter interface {\n\t// Get locates the Resource with the given name in the current context (e.g. in .Page.Resources).\n\t//\n\t// It returns nil if no Resource could found, panics if name is invalid.\n\tGet(name any) Resource\n}\n\ntype IsProbablySameResourceGetter interface {","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/resource/resources.go#L246-L282","documentation":"Returned by `Resources.MergeByLanguageInterface` (resources.go:261-267) when the argument cannot be asserted to `Resources`. This method is the generic `any`-typed entry point exposed so the template runtime can call `merge` on a resource list; it type-narrows at resources.go:262-264 and rejects anything that is not a `resource.Resources` slice.","triggerScenarios":"A template calls the `merge` resource function with a non-Resources value: a single Resource, a `[]any` of resources (rather than `Resources`), a Pages slice, nil, or a string.","commonSituations":"Template plumbing passing a `slice` result (which is `[]any`) into `merge` instead of `.Resources`; calling `merge` on a Page where `.Resources` was intended; upgrading Hugo where merge input typing tightened.","solutions":["Pass a typed `resource.Resources` value -- typically `.Resources` from a page bundle or `resources.Match`/`resources.Get` results.","If you have a `[]any`, build a Resources slice via `collections.Slice` first.","Ensure the template variable is not nil or a single Resource."],"exampleFix":"// template -- before\n{{ $merged := merge $resources (slice $r1 $r2) }}\n\n// after\n{{ $extra := resources.Match \"img/**\" }}\n{{ $merged := merge $resources $extra }}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isResources(v any) bool {\n\t_, ok := v.(resource.Resources)\n\treturn ok\n}","tryCatchPattern":null,"preventionTips":["Pass `.Resources` / `resources.Match` results directly to `merge`.","Normalize `[]any` via `collections.Slice` before merging.","Avoid passing `Pages` to resource merge."],"tags":["templates","resources","merge","type-mismatch"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}