{"record":{"id":"e65faacdbf09fe79","repo":"gohugoio/hugo","slug":"key-is-neither-a-field-nor-a-method-of-page","errorCode":null,"errorMessage":"{key} is neither a field nor a method of Page","messagePattern":"(.+?) is neither a field nor a method of Page","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/pagegroup.go","lineNumber":143,"sourceCode":"\tvar ft any\n\tindex := hreflect.GetMethodIndexByName(pagePtrType, key)\n\tif index != -1 {\n\t\tm := pagePtrType.Method(index)\n\t\tif m.Type.NumOut() == 0 || m.Type.NumOut() > 2 {\n\t\t\treturn nil, errors.New(key + \" is a Page method but you can't use it with GroupBy\")\n\t\t}\n\t\tif m.Type.NumOut() == 1 && m.Type.Out(0).Implements(errorType) {\n\t\t\treturn nil, errors.New(key + \" is a Page method but you can't use it with GroupBy\")\n\t\t}\n\t\tif m.Type.NumOut() == 2 && !m.Type.Out(1).Implements(errorType) {\n\t\t\treturn nil, errors.New(key + \" is a Page method but you can't use it with GroupBy\")\n\t\t}\n\t\tft = m\n\t} else {\n\t\tvar ok bool\n\t\tft, ok = pagePtrType.Elem().FieldByName(key)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(key + \" is neither a field nor a method of Page\")\n\t\t}\n\t}\n\n\tvar tmp reflect.Value\n\tswitch e := ft.(type) {\n\tcase reflect.StructField:\n\t\ttmp = reflect.MakeMap(reflect.MapOf(e.Type, pagesType))\n\tcase reflect.Method:\n\t\ttmp = reflect.MakeMap(reflect.MapOf(e.Type.Out(0), pagesType))\n\t}\n\n\tfor _, e := range p {\n\t\tppv := reflect.ValueOf(e)\n\t\tvar fv reflect.Value\n\t\tswitch ft.(type) {\n\t\tcase reflect.StructField:\n\t\t\tfv = ppv.Elem().FieldByName(key)\n\t\tcase reflect.Method:","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/pagegroup.go#L125-L161","documentation":"`GroupBy` first looks the key up as a method; if not found it tries the Page struct field via `FieldByName` (pagegroup.go:141-143). If neither matches, the key is genuinely unknown and grouping cannot proceed.","triggerScenarios":"Calling `{{ .Pages.GroupBy \"Foo\" }}` where `Foo` is neither an exported Page method nor an exported Page struct field — e.g. a typo, a param name, or a removed field.","commonSituations":"Typo in the field/method name; trying to group by a front-matter param (use GroupByParam instead); referencing a field removed in a Hugo version upgrade; case sensitivity mistakes.","solutions":["Verify the name is an exported Page field or method (see Hugo's Page object docs).","For front-matter params, use `{{ .Pages.GroupByParam \"myparam\" }}` instead of GroupBy.","Check spelling and capitalization."],"exampleFix":"{{/* before: not a Page field/method */}}\n{{ .Pages.GroupBy \"myauthor\" }}\n\n{{/* after: group by a front matter param */}}\n{{ .Pages.GroupByParam \"myauthor\" }}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use GroupByParam for front-matter params, GroupBy for Page fields/methods.","Verify the name against Hugo's Page object reference."],"tags":["hugo","templates","groupby","reflection"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}