gohugoio/hugo · error
padding values must not exceed 5000 pixels
Error message
padding values must not exceed 5000 pixels
What it means
Thrown by images.Padding when any individual padding value exceeds 5000 pixels (filters.go:170-174). The cap guards against accidentally generating enormous canvases that would exhaust memory.
Source
Thrown at resources/images/filters.go:173
_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:
top, right, bottom, left = vals[0], vals[1], vals[2], vals[1]
case 4:
top, right, bottom, left = vals[0], vals[1], vals[2], vals[3]
default:
panic(fmt.Sprintf("too many padding values: received %d, expected maximum of 4", len(args)))
}
return filter{View on GitHub (pinned to 52c9bd7908)
Solutions
- Reduce each padding value to 5000 or fewer pixels.
- Double-check the source of dynamic padding values (e.g. multiplied dimensions).
- If you genuinely need a larger canvas, reconsider whether padding is the right tool.
Example fix
// before
{{ $filters = $filters | append (images.Padding 20000) }}
// after
{{ $filters = $filters | append (images.Padding 2000) }} Defensive patterns
Strategy: validation
Validate before calling
{{ range $v := .paddings }}
{{ if gt (int $v) 5000 }}{{ errorf "padding %v exceeds 5000px" $v }}{{ end }}
{{ end }} Prevention
- Clamp computed padding values to <= 5000.
- Review multipliers feeding padding numbers.
- Prefer moderate padding; very large canvases waste memory.
When it happens
Trigger: Passing a padding value greater than 5000, e.g. images.Padding 9999. Each value is checked after cast.ToInt conversion.
Common situations: Unit confusion (using a multiplier), copy-paste of a large dimension, or a template variable holding an unintended large number.
Related errors
- the padding filter requires between 1 and 5 arguments
- invalid canvas color: specify RGB or RGBA using hex notation
- not enough arguments: provide one or more padding values usi
- too many padding values: received %d, expected maximum of 4
- final image width will be less than 1 pixel: check padding v
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/42afd708076d079a.
Report an issue: GitHub.