gohugoio/hugo · error
too many arguments to .Site.GetPage: %v. Use lookups on the
Error message
too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage "/posts/mypage-md" }} What it means
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.
Source
Thrown at hugolib/pagecollections.go:95
// This is invoked when you do .Site.GetPage. We drop the Kind and fails
// if there are more than 2 arguments, which would be ambiguous.
func (c *pageFinder) getPageForRefs(ref ...string) (page.Page, error) {
var refs []string
for _, r := range ref {
// A common construct in the wild is
// .Site.GetPage "home" "" or
// .Site.GetPage "home" "/"
if r != "" && r != "/" {
refs = append(refs, r)
}
}
var key string
if len(refs) > 2 {
// This was allowed in Hugo <= 0.44, but we cannot support this with the
// new API. This should be the most unusual case.
return nil, fmt.Errorf(`too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage "/posts/mypage-md" }}`, ref)
}
if len(refs) == 0 || refs[0] == kinds.KindHome {
key = "/"
} else if len(refs) == 1 {
if len(ref) == 2 && refs[0] == kinds.KindSection {
// This is an old style reference to the "Home Page section".
// Typically fetched via {{ .Site.GetPage "section" .Section }}
// See https://github.com/gohugoio/hugo/issues/4989
key = "/"
} else {
key = refs[0]
}
} else {
key = refs[1]
}
return c.getPage(nil, key)View on GitHub (pinned to 52c9bd7908)
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"`.
Example fix
{{/* before */}}
{{ .Site.GetPage "section" .Section "index" }}
{{/* after */}}
{{ .Site.GetPage (printf "/%s" .Section) }} Defensive patterns
Strategy: validation
Validate before calling
# Grep for legacy 3+ arg GetPage calls before building. grep -rnE 'GetPage[[:space:]]+"[^"]+"[[:space:]]+"[^"]+"[[:space:]]+' layouts content archetypes || true
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid arguments to Ref: %w
- can't apply the operator to the values
- quality ranges from 1 to 100 inclusive
- invalid image dimensions
- must provide Width and Height
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/527a0029c2b2b42c.
Report an issue: GitHub.