gohugoio/hugo · error

'increment' must be > 0

Error message

'increment' must be > 0

What it means

Thrown by Seq in the 3-argument form when first < last but the increment is negative (line 463). A negative step cannot reach a larger 'last' from a smaller 'first', so the call is contradictory and rejected. This prevents a silently-empty or infinite result.

Source

Thrown at tpl/collections/collections.go:464

		} 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, errSeqSizeExceedsLimit
	}

	seq := make([]int, size)

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Match the step sign to the direction: ascending => positive step ({{ seq 1 1 10 }}).
  2. If you want descending from high to low, call {{ seq 10 -1 1 }} (first > last, negative step).
  3. Double-check argument order: it is start, increment, end.

Example fix

// before
{{ seq 1 -1 10 }}
// after
{{ seq 1 1 10 }}
Defensive patterns

Strategy: validation

Validate before calling

{{/* ascending: positive step */}}
{{ seq 1 1 10 }}

Prevention

When it happens

Trigger: Calling {{ seq 1 -1 10 }} (start 1, end 10, but step -1); passing swapped start/end with the wrong sign on step; computed start/end where the order assumption is inverted.

Common situations: Swapping start and end without flipping the step sign; reusing a 'decrement' template snippet in an ascending context; off-by confusion about argument order (start, increment, end).

Related errors


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