{"id":"b4fcd2b992af4502","repo":"gohugoio/hugo","slug":"too-many-arguments-pager-size-is-currently-the","errorCode":null,"errorMessage":"too many arguments, 'pager size' is currently the only option","messagePattern":"too many arguments, 'pager size' is currently the only option","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/pagination.go","lineNumber":270,"sourceCode":"\t\t\t\tkey = kp.key\n\t\t\t\tpg = append(pg, PageGroup{Key: key})\n\t\t\t\tgroupIndex++\n\t\t\t}\n\t\t\tpg[groupIndex].Pages = append(pg[groupIndex].Pages, kp.page)\n\t\t}\n\t\tsplit = append(split, pg)\n\t}\n\n\treturn split\n}\n\nfunc ResolvePagerSize(conf config.AllProvider, options ...any) (int, error) {\n\tif len(options) == 0 {\n\t\treturn conf.Pagination().PagerSize, nil\n\t}\n\n\tif len(options) > 1 {\n\t\treturn -1, errors.New(\"too many arguments, 'pager size' is currently the only option\")\n\t}\n\n\tpas, err := cast.ToIntE(options[0])\n\n\tif err != nil || pas <= 0 {\n\t\treturn -1, errors.New((\"'pager size' must be a positive integer\"))\n\t}\n\n\treturn pas, nil\n}\n\nfunc Paginate(td TargetPathDescriptor, seq any, pagerSize int) (*Paginator, error) {\n\tif pagerSize <= 0 {\n\t\treturn nil, errors.New(\"'paginate' configuration setting must be positive to paginate\")\n\t}\n\n\turlFactory := newPaginationURLFactory(td)\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/pagination.go#L252-L288","documentation":"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.","triggerScenarios":"Template calls like `{{ .Paginate .Pages 10 20 }}` or `{{ .Paginate .Pages 10 \"foo\" }}` — anything with two or more arguments after the page collection.","commonSituations":"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.","solutions":["Call .Paginate with at most one option: `{{ .Paginate .Pages 10 }}`","Set the default pager size in site config (`pagination.pagerSize`) instead of passing arguments","Remove the extra argument; there is no offset/start parameter"],"exampleFix":"// before\n{{ $pag := .Paginate .Pages 10 20 }}\n// after\n{{ $pag := .Paginate .Pages 10 }}","handlingStrategy":"validation","validationCode":"{{/* correct: */}}{{ $pag := .Paginate .Pages 5 }}{{/* wrong: .Paginate .Pages 5 \"extra\" */}}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call .Paginate with at most two arguments: the collection and an optional integer page size","Configure default page size via pagination.pagerSize in site config instead of passing it everywhere","Audit templates after upgrades for stale multi-argument Paginate calls"],"tags":["hugo","pagination","templates","arguments"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}