{"id":"5402eba0649b8774","repo":"gohugoio/hugo","slug":"unwrappage-t-not-supported","errorCode":null,"errorMessage":"unwrapPage: %T not supported","messagePattern":"unwrapPage: %T not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page_unwrap.go","lineNumber":42,"sourceCode":"type pageWrapper interface {\n\tpage() page.Page\n}\n\n// unwrapPage is used in equality checks and similar.\nfunc unwrapPage(in any) (page.Page, error) {\n\tswitch v := in.(type) {\n\tcase *pageState:\n\t\treturn v, nil\n\tcase pageWrapper:\n\t\treturn v.page(), nil\n\tcase types.Unwrapper:\n\t\treturn unwrapPage(v.Unwrapv())\n\tcase page.Page:\n\t\treturn v, nil\n\tcase nil:\n\t\treturn nil, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unwrapPage: %T not supported\", in)\n\t}\n}\n\nfunc mustUnwrapPage(in any) page.Page {\n\tp, err := unwrapPage(in)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn p\n}\n","sourceCodeStart":24,"sourceCodeEnd":54,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page_unwrap.go#L24-L54","documentation":"Raised by `unwrapPage` in hugolib/page_unwrap.go:42, a helper used in page equality checks and comparisons (e.g. `.IsAncestor`, `.Eq`, `in`-style checks). It accepts a `*pageState`, a `pageWrapper`, a `types.Unwrapper`, a `page.Page`, or nil; any other type — a string, a resource, a map, a slice of pages — falls to the default case and this error reports the unsupported Go type via `%T`. Callers going through `mustUnwrapPage` turn it into a panic.","triggerScenarios":"Templates passing a non-Page value where a Page is expected: e.g. `{{ if $p.Eq .Site.Home.Permalink }}` (a string), `.IsAncestor .Sections` (a slice), or passing a Resource/partial result into page-comparison functions.","commonSituations":"Template code comparing a page against a path or permalink string instead of the page object; iterating a menu and passing `.URL` instead of `.Page`; custom partials that lose the page type by converting it; theme incompatibilities after Hugo type changes.","solutions":["Find the template call in the error's stack/context and pass an actual Page object (e.g. `.Site.GetPage \"/about\"`) instead of a string/permalink.","For menu entries, use `.Page` (with a nil check) rather than `.URL` when calling page-comparison methods.","If comparing by path is what you want, compare strings directly (`eq $p.RelPermalink $other`) instead of using page equality helpers."],"exampleFix":"{{/* before */}}\n{{ if .IsAncestor .Site.Home.RelPermalink }}...{{ end }}\n\n{{/* after */}}\n{{ if .IsAncestor .Site.Home }}...{{ end }}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func asPage(v any) (page.Page, bool) {\n    p, ok := v.(page.Page)\n    return p, ok\n}\n// in templates: {{ if eq (printf \"%T\" .) \"*hugolib.pageState\" }} — or better: {{ with .Page }}...{{ end }}","tryCatchPattern":null,"preventionTips":["Only pass real Page values to functions/partials expecting pages — don't hand them shortcode contexts, Sites, or dicts","In templates, use `.Page` from shortcode/render-hook contexts to obtain the underlying page before passing it on","When writing template code that accepts mixed input, guard with `with`/type checks before calling page-only methods"],"tags":["hugo","templates","type-error"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}