gohugoio/hugo · error

not enough arguments: provide one or more padding values usi

Error message

not enough arguments: provide one or more padding values using the CSS shorthand property syntax

What it means

Thrown by images.Padding when the only argument supplied is consumed as the canvas color, leaving zero padding values (filters.go:163-166). Padding requires at least one pixel value; a lone color is not enough.

Source

Thrown at resources/images/filters.go:165

// signature is images.Padding V1 [V2] [V3] [V4] [COLOR].
func (*Filters) Padding(args ...any) gift.Filter {
	if len(args) < 1 || len(args) > 5 {
		panic("the padding filter requires between 1 and 5 arguments")
	}

	var top, right, bottom, left int
	var ccolor color.Color = color.White // canvas color

	_args := args // preserve original args for most stable hash

	if vcs, ok, err := toColorGo(args[len(args)-1]); ok || err != nil {
		if err != nil {
			panic("invalid canvas color: specify RGB or RGBA using hex notation")
		}
		ccolor = vcs
		args = args[:len(args)-1]
		if len(args) == 0 {
			panic("not enough arguments: provide one or more padding values using the CSS shorthand property syntax")
		}
	}

	var vals []int
	for _, v := range args {
		vi := cast.ToInt(v)
		if vi > 5000 {
			panic("padding values must not exceed 5000 pixels")
		}
		vals = append(vals, vi)
	}

	switch len(args) {
	case 1:
		top, right, bottom, left = vals[0], vals[0], vals[0], vals[0]
	case 2:
		top, right, bottom, left = vals[0], vals[1], vals[0], vals[1]
	case 3:

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Always include at least one pixel value before the optional color.
  2. Reorder so the color is the trailing argument and pixels precede it.
  3. If you want default white padding, pass the pixel values explicitly (color defaults to white when omitted).

Example fix

// before
{{ $filters = $filters | append (images.Padding "#ffffff") }}
// after
{{ $filters = $filters | append (images.Padding 10 "#ffffff") }}
Defensive patterns

Strategy: validation

Validate before calling

{{ if and (eq (len $args) 1) (reflect.IsMap (index $args 0)) }}
  {{ errorf "Padding needs at least one pixel value" }}
{{ end }}

Prevention

When it happens

Trigger: Calling images.Padding with exactly one argument that is a valid color, e.g. images.Padding "#ffffff". The color is consumed and no padding values remain.

Common situations: Developer intends to pad with defaults and just names the color, not realizing pixel values are mandatory; or a template conditionally omits the numeric padding when a color is present.

Related errors


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