{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/navigation/pagemenus.go#L55-L91","documentation":"Thrown by PageMenusFromPage (navigation/pagemenus.go:73) via the wrapErr closure when the page's front-matter 'menu' value cannot be interpreted as a string, a slice of strings, or a map of menu entries. The %w wraps the underlying error from hmaps.ToStringMapE (the value is not a map) or mapstructure.WeakDecode (a menu entry field has the wrong type). It names the offending page via p.Path().","triggerScenarios":"A content file sets menu in front matter to an unsupported shape — e.g. menu = 123 (scalar number), menu = [[\"a\"],[\"b\"]] (nested slice), or a map whose nested entry is not itself a map (menu.main = \"just-a-string-but-also-not\". structured incorrectly). The cast.ToStringE and cast.ToStringSliceE both fail, then hmaps.ToStringMapE(ms) or ToStringMapE(menu) fails, triggering wrapErr.","commonSituations":"Switching front-matter format (YAML to TOML) and forgetting to adjust the menu table syntax; copy-pasting a menu config example that uses a different structure; providing menu: { main: [1,2,3] } where a nested object is expected; using a numeric or boolean value where a string/menu-map is required.","solutions":["Open the page named in the error message and fix its front-matter 'menu' field to be a string, a list of strings, or a map of menu-entry objects.","Validate nested menu entries are maps with recognized keys (name, weight, parent, identifier, url, pre, post).","Run hugo --templateMetricsHints or a local build to confirm the error clears after the edit.","If the value is intentionally dynamic, move it into a valid structure under [menus] in the site config instead of page front matter."],"exampleFix":"# before (invalid nested type)\n---\nmenu:\n  main: 42\n---\n\n# after\n---\nmenu:\n  main:\n    name: \"About\"\n    weight: 1\n---","handlingStrategy":"validation","validationCode":"// Validate page front-matter 'menu' before passing to PageMenusFromPage.\nfunc validateMenuValue(ms any) error {\n    switch v := ms.(type) {\n    case string, []string, []any, map[string]any:\n        return nil\n    default:\n        return fmt.Errorf(\"menu must be string, []string, or map; got %T\", v)\n    }\n}","typeGuard":"func isValidMenuShape(ms any) bool {\n    switch ms.(type) {\n    case string, []string, []any, map[string]any, nil:\n        return true\n    }\n    return false\n}","tryCatchPattern":"pm, err := navigation.PageMenusFromPage(ms, p)\nif err != nil {\n    // err already wraps the page path; log and skip this page's menus.\n    hugrot.Printf(\"skipping menus for %s: %v\", p.Path(), err)\n}","preventionTips":["Use Hugo's documented menu front-matter shapes only: string, list of strings, or a map of entry maps.","Validate front matter with a schema/lint step in CI.","When migrating front-matter formats, re-check nested menu tables."],"tags":["menus","front-matter","navigation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}