How can I have two files with the same title in different places?

Our site using Hugo has several groups of markdown files that share the same title, but are differentiated by their file path and name. When trying to build the site, hugo puts out errors like

Two or more menu items have the same name/identifier in Menu “main”: “Notifications”.

Is there any way that two files can have the same title as long as they sit in different paths?

The error is about duplicate menu items. Looks like you have two menu items with same identifier (Notifications). Pick one of them and set an unique identifier (can be anything).

My question was whether it’s possible to have two articles with the same Title. But I guess it’s not?

Yes it is.

I have a dual language site with content files with the same name and slug, but in separate folders.

If you specify menus in front-matter, copy pasting can cause trouble. Be sure to change the identifier as @bep mentioned. I got the same error but checked all menu items in config files and frontmatter to find the dupe.

You set title in front matter. Nothing prevents you from using the same title more than once.

1 Like

I am working on the same project as @heyx3

What is the distinction between identifiers and title?

Here is our current front matter from two articles:

---
date: 2015-06-02T13:03:43-04:00
weight: 7
title: Notifications
menu:
  main:
    parent: integrating_ios
---
---
date: 2015-06-02T13:03:43-04:00
weight: 4
title: Notifications
menu:
  main:
    parent: integrating_ios_marmalade
---

This leads to the error in the OP:

ERROR: 2015/06/10 Two or more menu items have the same name/identifier in Menu “main”: “Notifications”.
Rename or set an unique identifier.

Is the core issue that that they sure the same grandparent menu main?

identifier is an attribute on a menu item.

I guess it picks the page title as the menu item name if not set.

To fix your issue, do something like this:

---
date: 2015-06-02T13:03:43-04:00
weight: 4
title: Notifications
menu:
  main:
    parent: integrating_ios_marmalade
    identifier: some_value
---
1 Like

Ah thanks. That works.

So identifier is based on title unless identifier is explicitly set? And there is no relation between identifier and the filename?

The identifier is used to identify a menu item. So it must be unique within a menu (or the duplicate will be ignored – hence the error message).

It gets it value from menu item name if not set. I haven’t looked so I’m not 100% sure what value is used as key if neither are set. The main thing is: To fix this, add an identifier to one of the duplicates.

Makes sense. Thanks for the help @bep

I ran into this problem. I had two files with the same “title” both off of [main.menu] but different parents. I was able to fix it by adding an identifier to one of the files. Took a long time to debug — I am building a single site by drawing content from multiple GIHub repos.

Debugging took a bit because my content was coming from 6 different locations. It would great if Hugo were to throw an error when it encounters duplicate identifiers or titles (when identifiers are not in use.)

1 Like