gohugoio/hugo · error

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

Error message

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

What it means

Returned by ResolvePagerSize when .Paginate/.Paginator is called with more than one option argument. Hugo currently accepts only a single optional argument — the pager size — so any extra positional argument is rejected.

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 8a468df065)

Solutions

  1. Call .Paginate with at most one option: `{{ .Paginate .Pages 10 }}`
  2. Set the default pager size in site config (`pagination.pagerSize`) instead of passing arguments
  3. Remove the extra argument; there is no offset/start parameter

Example fix

// before
{{ $pag := .Paginate .Pages 10 20 }}
// after
{{ $pag := .Paginate .Pages 10 }}
Defensive patterns

Strategy: validation

Validate before calling

{{/* correct: */}}{{ $pag := .Paginate .Pages 5 }}{{/* wrong: .Paginate .Pages 5 "extra" */}}

Prevention

When it happens

Trigger: Template calls like `{{ .Paginate .Pages 10 20 }}` or `{{ .Paginate .Pages 10 "foo" }}` — anything with two or more arguments after the page collection.

Common situations: Guessing the API and passing an offset/start-page as a second argument, porting pagination code from other frameworks, or accidental extra arguments from template refactors.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/b4fcd2b992af4502.json. Report an issue: GitHub ↗.