gohugoio/hugo · error
too many arguments
Error message
too many arguments
What it means
Thrown by strings.SliceString when more than two index arguments are passed. SliceString accepts at most a start and an end index; a third index or more is a usage error.
Solutions
- Pass at most two indices: {{ strings.SliceString $s $start $end }}.
- Use a single index to slice to the end: {{ strings.SliceString $s $start }}.
- If you need a step, chain SliceString calls instead.
Example fix
// before
{{ strings.SliceString $s 0 5 10 }}
// after
{{ strings.SliceString $s 0 5 }} Defensive patterns
Strategy: validation
Validate before calling
{{ strings.SliceString $s $start $end }} Prevention
- Pass at most two indices to SliceString.
- Use a single index to slice to the end.
- Chain calls instead of passing a step argument.
When it happens
Trigger: Calling {{ strings.SliceString $s 0 5 10 }} or any call with three or more indices.
Common situations: Copy-paste from a function that takes more args; misunderstanding that SliceString is a half-open two-index range; passing a slice of indices.
Related errors
- too few arguments
- end argument must be integer
- must not provide more arguments than Resource and hash…
- must provide a Resource and optionally an options map
- must provide a Resource object
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/89e289404fb55ce0.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/strings/strings.go:340
}
var argStart, argEnd int
argNum := len(startEnd)
if argNum > 0 {
if argStart, err = cast.ToIntE(startEnd[0]); err != nil {
return "", errors.New("start argument must be integer")
}
}
if argNum > 1 {
if argEnd, err = cast.ToIntE(startEnd[1]); err != nil {
return "", errors.New("end argument must be integer")
}
}
if argNum > 2 {
return "", errors.New("too many arguments")
}
asRunes := []rune(aStr)
if argNum > 0 && (argStart < 0 || argStart >= len(asRunes)) {
return "", errors.New("slice bounds out of range")
}
if argNum == 2 {
if argEnd < 0 || argEnd > len(asRunes) {
return "", errors.New("slice bounds out of range")
}
return string(asRunes[argStart:argEnd]), nil
} else if argNum == 1 {
return string(asRunes[argStart:]), nil
} else {
return string(asRunes[:]), nil
}View on GitHub (pinned to 52c9bd7908)