gohugoio/hugo · error

must provide a Resource object

Error message

must provide a Resource object

What it means

Thrown by resources.Fingerprint when called with no arguments. Fingerprint requires at least a Resource object (and optionally a hash algorithm string as the first argument). Calling {{ resources.Fingerprint }} with nothing triggers this.

Solutions

  1. Pass a resource: {{ $r | resources.Fingerprint }} or {{ resources.Fingerprint $r }}.
  2. Optionally pass an algorithm first: {{ resources.Fingerprint "sha512" $r }}.
  3. Ensure the resource variable is non-nil before calling.

Example fix

// before
{{ resources.Fingerprint }}
// after
{{ $css | resources.Fingerprint }}
Defensive patterns

Strategy: validation

Validate before calling

{{ with $r }}{{ resources.Fingerprint . }}{{ end }}

Prevention

When it happens

Trigger: Calling {{ resources.Fingerprint }} directly, or piping nothing into it: {{ $nil | resources.Fingerprint }}.

Common situations: Forgetting to pass the resource; piping a nil resource variable; refactoring that dropped the argument.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/259a8b2f316a6fdc. Report an issue: GitHub.

Appendix: source

Thrown at tpl/resources/resources.go:266

	targetPath, err := cast.ToStringE(args[0])
	if err != nil {
		return nil, err
	}
	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
		}
	}

View on GitHub (pinned to 52c9bd7908)