{"record":{"id":"527a0029c2b2b42c","repo":"gohugoio/hugo","slug":"too-many-arguments-to-site-getpage-v-use-looku","errorCode":null,"errorMessage":"too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage \"/posts/mypage-md\" }}","messagePattern":"too many arguments to \\.Site\\.GetPage: (.+?)\\. Use lookups on the form (.+?)\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/pagecollections.go","lineNumber":95,"sourceCode":"// This is invoked when you do .Site.GetPage. We drop the Kind and fails\n// if there are more than 2 arguments, which would be ambiguous.\nfunc (c *pageFinder) getPageForRefs(ref ...string) (page.Page, error) {\n\tvar refs []string\n\tfor _, r := range ref {\n\t\t// A common construct in the wild is\n\t\t// .Site.GetPage \"home\" \"\" or\n\t\t// .Site.GetPage \"home\" \"/\"\n\t\tif r != \"\" && r != \"/\" {\n\t\t\trefs = append(refs, r)\n\t\t}\n\t}\n\n\tvar key string\n\n\tif len(refs) > 2 {\n\t\t// This was allowed in Hugo <= 0.44, but we cannot support this with the\n\t\t// new API. This should be the most unusual case.\n\t\treturn nil, fmt.Errorf(`too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage \"/posts/mypage-md\" }}`, ref)\n\t}\n\n\tif len(refs) == 0 || refs[0] == kinds.KindHome {\n\t\tkey = \"/\"\n\t} else if len(refs) == 1 {\n\t\tif len(ref) == 2 && refs[0] == kinds.KindSection {\n\t\t\t// This is an old style reference to the \"Home Page section\".\n\t\t\t// Typically fetched via {{ .Site.GetPage \"section\" .Section }}\n\t\t\t// See https://github.com/gohugoio/hugo/issues/4989\n\t\t\tkey = \"/\"\n\t\t} else {\n\t\t\tkey = refs[0]\n\t\t}\n\t} else {\n\t\tkey = refs[1]\n\t}\n\n\treturn c.getPage(nil, key)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/pagecollections.go#L77-L113","documentation":"Raised by getPageForRefs (pagecollections.go:95) — the adapter behind .Site.GetPage — when more than two non-empty arguments are passed. Hugo <= 0.44 allowed (Kind, ref) pairs; the modern API takes a single path string, and >2 args cannot be disambiguated. Empty strings and \"/\" are filtered before the count, so genuinely 3+ real refs are required.","triggerScenarios":"Old templates from Hugo 0.44 or earlier calling `.Site.GetPage \"section\" .Section \"extra\"` or any 3+ argument form; passing a slice that expands to multiple args; copy-pasted examples that include the legacy Kind argument plus extras.","commonSituations":"Upgrading an old site/theme that predates the 0.45 page-API rewrite; themes cloned from vintage examples; forgetting to remove the old Kind param when modernizing.","solutions":["Replace the call with the modern single-path form: `.Site.GetPage \"/posts/mypage.md\"`.","If you need the home page, use `.Site.GetPage \"/\"` or `.GetPage \"/\"`.","For section lookups use `.Site.GetPage \"/mysection\"`."],"exampleFix":"{{/* before */}}\n{{ .Site.GetPage \"section\" .Section \"index\" }}\n\n{{/* after */}}\n{{ .Site.GetPage (printf \"/%s\" .Section) }}","handlingStrategy":"validation","validationCode":"# Grep for legacy 3+ arg GetPage calls before building.\ngrep -rnE 'GetPage[[:space:]]+\"[^\"]+\"[[:space:]]+\"[^\"]+\"[[:space:]]+' layouts content archetypes || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only the single-path .Site.GetPage form in all templates.","Audit themes upgraded from Hugo <= 0.44 for legacy Kind-prefixed calls.","Add a lint rule/grep in CI to flag multi-argument GetPage calls."],"tags":["ref","api","migration","templates"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}