gohugoio/hugo · error

must not provide more arguments than resource object and opt

Error message

must not provide more arguments than resource object and options

What it means

css.PostCSS, css.TailwindCSS (and css.Sass via ResolveArgs) accept at most two arguments: the resource to transform and an optional options map. Because these are variadic template functions, Hugo validates the count explicitly and rejects three or more arguments before resolving them.

Source

Thrown at tpl/css/css.go:110

	})
}

// Quoted returns a string that needs to be quoted in CSS.
func (ns *Namespace) Quoted(v any) css.QuotedString {
	s := cast.ToString(v)
	return css.QuotedString(s)
}

// Unquoted returns a string that does not need to be quoted in CSS.
func (ns *Namespace) Unquoted(v any) css.UnquotedString {
	s := cast.ToString(v)
	return css.UnquotedString(s)
}

// PostCSS processes the given Resource with PostCSS.
func (ns *Namespace) PostCSS(args ...any) (resource.Resource, error) {
	if len(args) > 2 {
		return nil, errors.New("must not provide more arguments than resource object and options")
	}

	r, m, err := resourcehelpers.ResolveArgs(args)
	if err != nil {
		return nil, err
	}

	return ns.postcssClient.Process(r, m)
}

// TailwindCSS processes the given Resource with tailwindcss.
func (ns *Namespace) TailwindCSS(args ...any) (resource.Resource, error) {
	if len(args) > 2 {
		return nil, errors.New("must not provide more arguments than resource object and options")
	}

	r, m, err := resourcehelpers.ResolveArgs(args)
	if err != nil {

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Collapse all options into a single dict: {{ $r = $r | css.PostCSS (dict "config" "postcss.config.js") }}.
  2. Remember piping supplies the resource as the last argument — don't also pass it explicitly.
  3. Check the function docs at gohugo.io/functions/css/ for the exact signature.

Example fix

{{/* before */}}
{{ $css := css.PostCSS $r "postcss.config.js" true }}

{{/* after */}}
{{ $css := $r | css.PostCSS (dict "config" "postcss.config.js") }}
Defensive patterns

Strategy: validation

Validate before calling

{{/* Correct: at most (options, resource) — not extra args */}}
{{ $opts := dict "transpiler" "dartsass" "targetPath" "css/main.css" }}
{{ $css := resources.Get "sass/main.scss" | css.Sass $opts }}

Prevention

When it happens

Trigger: Calling {{ $r | css.PostCSS $opts $extra }} or css.TailwindCSS with more than two values — commonly from piping a resource while also passing it positionally, or splitting a dict into multiple arguments.

Common situations: Template authors pass options as separate key/value arguments instead of one dict, or migrate from an older pattern and leave a stray argument; pipelines like {{ css.PostCSS "postcss.config.js" $r $opts }} also trip it.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/baae848bbde0331a.json. Report an issue: GitHub ↗.