{"record":{"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":"console","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/site.go#L1469-L1505","documentation":"While assembling site navigation, two menu entries resolved to the same identifier (KeyName) within the same menu. Hugo logs this as a warning (s.Log.Warnln) and keeps only the first entry, so it is non-fatal but produces an incomplete/incorrect menu. The duplicate typically arises when page front matter declares a menu entry whose identifier collides with one from sectionPagesMenu, another page, or the explicit menus config.","triggerScenarios":"Two pages both list menu: main under front matter with the same name/identifier; a page-level menu entry collides with an auto-generated sectionPagesMenu entry (site.go:1484-1490 checks the flat[twoD{name,key}] map before inserting).","commonSituations":"Setting sectionPagesMenu: main globally while also adding explicit menu entries in page front matter; multiple pages sharing the same title used as the menu identifier; renaming pages without updating menu identifiers.","solutions":["Make each menu entry's identifier unique by setting an explicit identifier (or name) in front matter: menu: main: { identifier: \"unique-id\" }.","Decide whether the duplicate should come from sectionPagesMenu or from front matter, and remove the other source.","Rebuild and confirm the warning no longer appears; verify the rendered menu has the intended entries."],"exampleFix":"// before (two pages, both)\n+++ \nmenu: { main: { name: \"Docs\" } }\n+++\n\n// after (give unique identifiers)\n+++ \nmenu: { main: { identifier: \"docs-intro\", name: \"Docs\" } }\n+++","handlingStrategy":"validation","validationCode":"// Before building, ensure every menu entry identifier is unique per menu.\nfunc validateMenuIDs(entries []MenuEntry) error {\n    seen := map[string]bool{}\n    for _, e := range entries {\n        key := e.Menu + \"/\" + e.Identifier\n        if seen[key] {\n            return fmt.Errorf(\"duplicate menu entry %q in menu %q\", e.Identifier, e.Menu)\n        }\n        seen[key] = true\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set an explicit, unique identifier for every front-matter menu entry.","Avoid combining sectionPagesMenu with overlapping explicit entries.","Search your content for duplicate 'menu:' identifiers during content audits."],"tags":["menu","navigation","config","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}