{"id":"daea2e2163a816a7","repo":"gohugoio/hugo","slug":"unable-to-process-menus-for-page-q-w","errorCode":null,"errorMessage":"unable to process menus for page %q: %w","messagePattern":"unable to process menus for page %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"navigation/pagemenus.go","lineNumber":73,"sourceCode":"\tif err == nil {\n\t\tme.Menu = mname\n\t\tpm[mname] = &me\n\t\treturn pm, nil\n\t}\n\n\t// Could be a slice of strings\n\tmnames, err := cast.ToStringSliceE(ms)\n\n\tif err == nil {\n\t\tfor _, mname := range mnames {\n\t\t\tme.Menu = mname\n\t\t\tpm[mname] = &me\n\t\t}\n\t\treturn pm, nil\n\t}\n\n\twrapErr := func(err error) error {\n\t\treturn fmt.Errorf(\"unable to process menus for page %q: %w\", p.Path(), err)\n\t}\n\n\t// Could be a structured menu entry\n\tmenus, err := hmaps.ToStringMapE(ms)\n\tif err != nil {\n\t\treturn pm, wrapErr(err)\n\t}\n\n\tfor name, menu := range menus {\n\t\tmenuEntry := MenuEntry{Menu: name}\n\t\tif menu != nil {\n\t\t\time, err := hmaps.ToStringMapE(menu)\n\t\t\tif err != nil {\n\t\t\t\treturn pm, wrapErr(err)\n\t\t\t}\n\t\t\tif err := mapstructure.WeakDecode(ime, &menuEntry.MenuConfig); err != nil {\n\t\t\t\treturn pm, err\n\t\t\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/navigation/pagemenus.go#L55-L91","documentation":"`PageMenusFromPage` (navigation/pagemenus.go:44) parses a page's front matter `menus`/`menu` key, which may be a string, a slice of strings, or a map of structured menu entries. When the value is none of those shapes — or a structured entry's value can't be converted to a string map — the underlying cast error is wrapped with the page's path so the user can locate the offending page.","triggerScenarios":"A page front matter `menus` value that fails both cast.ToStringE and cast.ToStringSliceE and then fails hmaps.ToStringMapE — e.g. `menu: 5`, a list of maps, or a nested value inside the menu map that isn't itself a map (navigation/pagemenus.go:77-88).","commonSituations":"Front matter typos like `menu: [ {name: Foo} ]` (array of maps instead of a map keyed by menu name), YAML indentation errors turning a map into a scalar/list, copy-pasting site-config menu syntax (which is a list) into page front matter where a map is expected.","solutions":["Open the page named in the error and fix the `menus` key: use a string (`menu: main`), a list of strings, or a map keyed by menu name with entry properties.","Convert site-config-style list entries (`menus: [{name: ...}]`) into the page-front-matter map form (`menus: { main: { weight: 10 } }`).","Validate the YAML/TOML indentation so each menu entry is a map under its menu name."],"exampleFix":"# before (page front matter)\nmenus:\n  - name: Home\n    weight: 1\n# after\nmenus:\n  main:\n    name: Home\n    weight: 1","handlingStrategy":"validation","validationCode":"# Validate front matter menu entries before building\n# menus must be a string, slice of strings, or map with known keys\nmenus:\n  main:\n    weight: 10  # numeric, not a string like \"heavy\"","typeGuard":null,"tryCatchPattern":"// Build-time error: wraps the underlying menu-parse failure per page\n// Fix the named page's front matter rather than catching at runtime\nif err := site.Build(); err != nil {\n    log.Fatalf(\"menu config error: %v\", err) // message names the offending page","preventionTips":["Keep the `menu`/`menus` front matter key a string, list of strings, or map — not arbitrary nested types","Validate menu entry fields (identifier, weight, parent, params) match documented types","Run `hugo --printPathWarnings` locally after editing menu front matter; the error names the offending page %q — fix it at the source"],"tags":["front-matter","menus","config","yaml"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}