gohugoio/hugo · error
'increment' must not be 0
Error message
'increment' must not be 0
What it means
Thrown by Seq in the 3-argument form when the increment (second argument) is exactly 0 (line 460). A zero step would loop infinitely (val += 0 never progresses), so it is rejected before the size is computed.
Solutions
- Use a non-zero increment: {{ seq 1 1 10 }} for step 1, {{ seq 10 -1 1 }} for step -1.
- Clamp the computed step away from zero: {{ $step := cond (eq $step 0) 1 $step }} {{ seq 1 $step 10 }}.
- Validate user-provided step params to reject 0 at the content/config level.
Example fix
// before
{{ seq 1 0 10 }}
// after
{{ seq 1 1 10 }} Defensive patterns
Strategy: validation
Validate before calling
{{ $step := cond (eq $step 0) 1 $step }}
{{ seq 1 $step 10 }} Prevention
- Never pass 0 as the increment in the 3-arg form.
- Clamp computed steps away from zero.
- Reject step=0 in user-configurable params.
When it happens
Trigger: Calling {{ seq 1 0 10 }} explicitly; passing a computed increment that resolves to 0 such as {{ seq 1 (sub $a $a) 10 }}; a front matter 'step' param set to 0.
Common situations: Dynamic step math collapsing to zero; user-configurable step params not bounded away from zero; defaulting a step variable to 0 by mistake.
Related errors
- 'increment' must be > 0
- 'increment' must be < 0
- size of result exceeds limit
- invalid arguments to Seq
- invalid number of arguments to Seq
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/fb7df680a7499257.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/collections/collections.go:461
last = first
if last == 0 {
return []int{}, nil
} else if last > 0 {
first = 1
} else {
first = -1
inc = -1
}
} else if len(intArgs) == 2 {
last = intArgs[1]
if last < first {
inc = -1
}
} else {
inc = intArgs[1]
last = intArgs[2]
if inc == 0 {
return nil, errors.New("'increment' must not be 0")
}
if first < last && inc < 0 {
return nil, errors.New("'increment' must be > 0")
}
if first > last && inc > 0 {
return nil, errors.New("'increment' must be < 0")
}
}
// sanity check
if last < -maxSeqSize {
return nil, errSeqSizeExceedsLimit
}
size := ((last - first) / inc) + 1
// sanity check
if size <= 0 || size > maxSeqSize {
return nil, errSeqSizeExceedsLimitView on GitHub (pinned to 52c9bd7908)