{"id":"092bd6b9b4dde834","repo":"gohugoio/hugo","slug":"t-can-not-be-transformed","errorCode":null,"errorMessage":"%T can not be transformed","messagePattern":"%T can not be transformed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/resources/resources.go","lineNumber":284,"sourceCode":"\tif len(args) > 2 {\n\t\treturn nil, errors.New(\"must not provide more arguments than Resource and hash algorithm\")\n\t}\n\n\tvar algo string\n\tresIdx := 0\n\n\tif len(args) == 2 {\n\t\tresIdx = 1\n\t\tvar err error\n\t\talgo, err = cast.ToStringE(args[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tr, ok := args[resIdx].(resources.ResourceTransformer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%T can not be transformed\", args[resIdx])\n\t}\n\n\treturn ns.integrityClient.Fingerprint(r, algo)\n}\n\n// Minify minifies the given Resource using the MediaType to pick the correct\n// minifier.\nfunc (ns *Namespace) Minify(r resources.ResourceTransformer) (resource.Resource, error) {\n\treturn ns.minifyClient.Minify(r)\n}\n\n// PostProcess processes r after the build.\n//\n// Deprecated: Use templates.Defer instead.\nfunc (ns *Namespace) PostProcess(r resource.Resource) (postpub.PostPublishedResource, error) {\n\thugo.DeprecateWithLogger(\"resources.PostProcess\", \"Use templates.Defer instead. See https://gohugo.io/functions/templates/defer/\", \"v0.164.0\", ns.deps.Log.Logger())\n\treturn ns.deps.ResourceSpec.PostProcess(r)\n}","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/resources/resources.go#L266-L302","documentation":"After parsing arguments, `resources.Fingerprint` type-asserts the resource argument to `resources.ResourceTransformer`. If the value at the resource position is not a transformable Resource (e.g. a string, nil, a Page, or a plain map), the assertion fails and Hugo reports the actual Go type via %T. Only resources obtained from resources.Get/GetMatch, page resources, or prior transformations implement this interface.","triggerScenarios":"`{{ resources.Fingerprint \"style.css\" }}` (passing a path string instead of a Resource), passing the result of `resources.Get` when the file wasn't found (nil), or swapping argument order so the algorithm string lands in the resource slot: `{{ resources.Fingerprint $res \"sha512\" }}`.","commonSituations":"resources.Get returning nil because the asset path doesn't exist under assets/ (common after moving files from static/ to assets/), argument-order mistakes when adding an algorithm, or passing a Page/string from theme code that expected a different function signature.","solutions":["Pass a real Resource: `{{ $css := resources.Get \"css/style.css\" }}{{ $fp := resources.Fingerprint $css }}`.","Guard against missing assets: `{{ with resources.Get \"css/style.css\" }}{{ $fp := . | fingerprint }}{{ end }}` — resources.Get returns nil if the file isn't in assets/.","Check argument order — the algorithm string comes first, the Resource last: `resources.Fingerprint \"sha256\" $res`.","Move the file from static/ to assets/ if you intended it to be part of the asset pipeline."],"exampleFix":"<!-- before -->\n{{ $fp := resources.Fingerprint \"css/style.css\" }}\n<!-- after -->\n{{ with resources.Get \"css/style.css\" }}\n  {{ $fp := resources.Fingerprint . }}\n{{ end }}","handlingStrategy":"type-guard","validationCode":"{{ $r := resources.Get \"styles.scss\" }}\n{{ if $r }}{{ with $r | resources.Minify }}...{{ end }}{{ end }}","typeGuard":"{{/* ensure the value is a transformable Resource, not a string/Page */}}\n{{ define \"partials/is-resource.html\" }}\n{{ return (and . (reflect.IsMap . | not) (isset . \"RelPermalink\")) }}\n{{ end }}","tryCatchPattern":null,"preventionTips":["Only pass Resource objects (from resources.Get, .Resources.Get, resources.FromString) to transform functions — never plain strings or Pages","Check `resources.Get` results with `with`/`if` before transforming; it returns nil for missing files","Don't pass Pages or page params where a Resource is expected; convert content with resources.FromString first"],"tags":["hugo","templates","resources","type-assertion","fingerprint"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}