gohugoio/hugo · error
must not provide more arguments than Resource and hash algor
Error message
must not provide more arguments than Resource and hash algorithm
What it means
Hugo's `resources.Fingerprint` template function accepts at most two arguments: an optional hash-algorithm string and a Resource object. When called with three or more arguments (len(args) > 2), it returns this error before any processing. The variadic signature exists to support both `resources.Fingerprint $res` and `resources.Fingerprint "sha512" $res` call forms.
Source
Thrown at tpl/resources/resources.go:267
data := args[1]
r, ok := args[2].(resources.ResourceTransformer)
if !ok {
return nil, fmt.Errorf("type %T not supported in Resource transformations", args[2])
}
return ns.templatesClient.ExecuteAsTemplate(ctx, r, targetPath, data)
}
// Fingerprint transforms the given Resource with a MD5 hash of the content in
// the RelPermalink and Permalink.
func (ns *Namespace) Fingerprint(args ...any) (resource.Resource, error) {
if len(args) < 1 {
return nil, errors.New("must provide a Resource object")
}
if len(args) > 2 {
return nil, errors.New("must not provide more arguments than Resource and hash algorithm")
}
var algo string
resIdx := 0
if len(args) == 2 {
resIdx = 1
var err error
algo, err = cast.ToStringE(args[0])
if err != nil {
return nil, err
}
}
r, ok := args[resIdx].(resources.ResourceTransformer)
if !ok {
return nil, fmt.Errorf("%T can not be transformed", args[resIdx])
}View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Reduce the call to at most two arguments: `{{ $fp := resources.Fingerprint $res }}` or `{{ $fp := resources.Fingerprint "sha512" $res }}`.
- With pipes, pass only the algorithm before the pipe: `{{ $res | fingerprint "sha512" }}.
- Remove any options map — Fingerprint only accepts an algorithm string (md5, sha256, sha384, sha512).
Example fix
<!-- before -->
{{ $fp := resources.Fingerprint "sha512" $css "integrity" }}
<!-- after -->
{{ $fp := resources.Fingerprint "sha512" $css }} Defensive patterns
Strategy: validation
Validate before calling
{{/* pass at most (Resource, algo) — build args explicitly, never splat */}}
{{ $r := resources.Get "img.png" }}
{{ $fp := $r | fingerprint "sha256" }} Prevention
- Call fingerprint with at most two args: the resource and an optional hash algorithm (md5, sha256, sha384, sha512)
- When piping (`$r | fingerprint`), remember the piped resource counts as the final argument — pass only the algorithm before the pipe
- Audit partials that forward `args...` to resource functions for accidental extra parameters
When it happens
Trigger: Calling `{{ resources.Fingerprint "sha256" $res "extra" }}` or piping while also passing two leading args, e.g. `{{ $res | fingerprint "sha512" "md5" }}` — anything that resolves to more than two total arguments to Fingerprint.
Common situations: Confusing argument order with other resource functions, passing options maps like js.Build/Babel accept (Fingerprint takes none), or accidentally duplicating the algorithm when converting between pipe and direct call syntax in templates copied from docs or themes.
Related errors
- must provide a Resource object
- %T can not be transformed
- need at least 2 arguments to append
- must provide a Resource and optionally an options map
- no Key set in Resource
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/490244e80710e3e0.json.
Report an issue: GitHub ↗.