gohugoio/hugo · error

too many arguments, 'pager size' is currently the only…

Error message

too many arguments, 'pager size' is currently the only option

What it means

`ResolvePagerSize` (pagination.go:264-271) accepts at most one option — the pager size. Passing more than one argument is ambiguous because no other option exists today, so the call is rejected.

Solutions

  1. Pass at most one argument: the pager size, e.g. `{{ .Paginate $pages 10 }}`.
  2. For default pager size, pass no options: `{{ .Paginator }}`.

Example fix

{{/* before */}}
{{ .Paginate $pages 10 20 }}

{{/* after */}}
{{ .Paginate $pages 10 }}
Defensive patterns

Strategy: validation

Validate before calling

if len(options) > 1 { return errors.New("too many arguments") }

Prevention

When it happens

Trigger: Calling `{{ .Paginate $pages 10 20 }}` or `{{ .Paginator 10 20 }}` — i.e. supplying two or more option arguments after the (optional) page set.

Common situations: Trying to pass both pager size and a sort/group option that doesn't exist; copy-paste adding an extra number; misunderstanding the variadic signature.

Related errors


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

Appendix: source

Thrown at resources/page/pagination.go:270

				key = kp.key
				pg = append(pg, PageGroup{Key: key})
				groupIndex++
			}
			pg[groupIndex].Pages = append(pg[groupIndex].Pages, kp.page)
		}
		split = append(split, pg)
	}

	return split
}

func ResolvePagerSize(conf config.AllProvider, options ...any) (int, error) {
	if len(options) == 0 {
		return conf.Pagination().PagerSize, nil
	}

	if len(options) > 1 {
		return -1, errors.New("too many arguments, 'pager size' is currently the only option")
	}

	pas, err := cast.ToIntE(options[0])

	if err != nil || pas <= 0 {
		return -1, errors.New(("'pager size' must be a positive integer"))
	}

	return pas, nil
}

func Paginate(td TargetPathDescriptor, seq any, pagerSize int) (*Paginator, error) {
	if pagerSize <= 0 {
		return nil, errors.New("'paginate' configuration setting must be positive to paginate")
	}

	urlFactory := newPaginationURLFactory(td)

View on GitHub (pinned to 52c9bd7908)