{"id":"f7f8b95d3135c24f","repo":"gohugoio/hugo","slug":"duplicate-menu-entry-with-identifier-q-in-menu-q","errorCode":null,"errorMessage":"duplicate menu entry with identifier %q in menu %q","messagePattern":"duplicate menu entry with identifier %q in menu %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hugolib/site.go","lineNumber":1487,"sourceCode":"\t\t\t\t\tName:       p.LinkTitle(),\n\t\t\t\t\tWeight:     p.Weight(),\n\t\t\t\t},\n\t\t\t\tPage: p,\n\t\t\t}\n\n\t\t\tnavigation.SetPageValues(&me, p)\n\t\t\tflat[twoD{sectionPagesMenu, me.KeyName()}] = &me\n\t\t\treturn false, nil\n\t\t}); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Add menu entries provided by pages\n\tif err := s.pageMap.forEachPage(pagePredicates.ShouldListGlobal, func(p *pageState) (bool, error) {\n\t\tfor name, me := range p.pageMenus.menus() {\n\t\t\tif _, ok := flat[twoD{name, me.KeyName()}]; ok {\n\t\t\t\terr := p.wrapError(fmt.Errorf(\"duplicate menu entry with identifier %q in menu %q\", me.KeyName(), name))\n\t\t\t\ts.Log.Warnln(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tflat[twoD{name, me.KeyName()}] = me\n\t\t}\n\t\treturn false, nil\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create Children Menus First\n\tfor _, e := range flat {\n\t\tif e.Parent != \"\" {\n\t\t\tchildren[twoD{e.Menu, e.Parent}] = children[twoD{e.Menu, e.Parent}].Add(e)\n\t\t}\n\t}\n\n\t// Placing Children in Parents (in flat)","sourceCodeStart":1469,"sourceCodeEnd":1505,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/site.go#L1469-L1505","documentation":"Produced while assembling menus (hugolib/site.go:1487) when two pages define menu entries that resolve to the same KeyName (identifier, or name if no identifier) within the same menu. Hugo logs it as a warning via p.wrapError and skips the duplicate entry rather than failing the build, keeping the first entry seen.","triggerScenarios":"Two or more pages with front matter menu definitions (menus: main with the same identifier, or same name and no identifier) in one menu; also a page menu entry colliding with an entry auto-generated by sectionPagesMenu.","commonSituations":"Copy-pasted front matter archetypes leaving identical menu identifiers, sectionPagesMenu combined with manual page menu entries for the same sections, or translated pages in a misconfigured multilingual setup both registering into one menu.","solutions":["Give each page's menu entry a unique identifier in front matter (identifier: about-us).","If names collide intentionally, add distinct identifier fields so KeyName differs.","When using sectionPagesMenu, remove manual front-matter menu entries for those section pages.","Search content front matter for the duplicated identifier: grep -r 'identifier:' content/"],"exampleFix":"# before (two pages)\nmenus:\n  main:\n    name: About\n# after (page 2)\nmenus:\n  main:\n    name: About\n    identifier: about-company","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, e := range menuEntries {\n    key := e.Menu + \"|\" + e.Identifier\n    if seen[key] {\n        return fmt.Errorf(\"duplicate identifier %q in menu %q\", e.Identifier, e.Menu)\n    }\n    seen[key] = true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every configured menu entry a unique identifier within its menu","Lint menu config (hugo.toml and page front matter menus) for duplicate identifiers in CI","When merging menus from config and front matter, namespace identifiers to avoid collisions"],"tags":["hugo","menu","front-matter","duplicate"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}