{"id":"fb7df680a7499257","repo":"gohugoio/hugo","slug":"increment-must-not-be-0","errorCode":null,"errorMessage":"'increment' must not be 0","messagePattern":"'increment' must not be 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/collections.go","lineNumber":461,"sourceCode":"\t\tlast = first\n\t\tif last == 0 {\n\t\t\treturn []int{}, nil\n\t\t} else if last > 0 {\n\t\t\tfirst = 1\n\t\t} else {\n\t\t\tfirst = -1\n\t\t\tinc = -1\n\t\t}\n\t} else if len(intArgs) == 2 {\n\t\tlast = intArgs[1]\n\t\tif last < first {\n\t\t\tinc = -1\n\t\t}\n\t} else {\n\t\tinc = intArgs[1]\n\t\tlast = intArgs[2]\n\t\tif inc == 0 {\n\t\t\treturn nil, errors.New(\"'increment' must not be 0\")\n\t\t}\n\t\tif first < last && inc < 0 {\n\t\t\treturn nil, errors.New(\"'increment' must be > 0\")\n\t\t}\n\t\tif first > last && inc > 0 {\n\t\t\treturn nil, errors.New(\"'increment' must be < 0\")\n\t\t}\n\t}\n\n\t// sanity check\n\tif last < -maxSeqSize {\n\t\treturn nil, errSeqSizeExceedsLimit\n\t}\n\tsize := ((last - first) / inc) + 1\n\n\t// sanity check\n\tif size <= 0 || size > maxSeqSize {\n\t\treturn nil, errSeqSizeExceedsLimit","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/collections/collections.go#L443-L479","documentation":"In the three-argument form of `seq` (FIRST INCREMENT LAST), the middle argument is the step. A zero increment would loop forever, so Hugo rejects it explicitly before computing the sequence size.","triggerScenarios":"`{{ seq 1 0 10 }}` — three arguments with the second equal to 0, or an increment variable that casts to 0 (e.g. a non-numeric string cast via `cast.ToIntSlice`).","commonSituations":"Increment sourced from front matter or site params that is unset or a string like \"0.5\" (which truncates to 0); mixing up the argument order (FIRST INCREMENT LAST, not FIRST LAST STEP).","solutions":["Pass a non-zero integer increment: `{{ seq 1 2 9 }}`.","Check argument order — the increment is the second of three arguments.","If the step comes from a variable, default it: `{{ $inc := default 1 .Params.step }}`."],"exampleFix":"<!-- before -->\n{{ seq 1 0 10 }}\n<!-- after -->\n{{ seq 1 1 10 }}","handlingStrategy":"validation","validationCode":"{{ if eq $increment 0 }}\n  {{ errorf \"seq increment must be non-zero\" }}\n{{ else }}\n  {{ range seq $first $increment $last }}...{{ end }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass 0 as the middle (increment) argument to the 3-arg seq form.","If the increment comes from site params, apply `default 1` and reject zero explicitly.","Watch integer truncation: a computed step like `div 1 2` is 0 in integer math."],"tags":["hugo","templates","seq","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}