<p>Technically it's a combination of the element's slug plus URI that is required to be unique (on a per-locale basis).</p>

<p>You can see the logic used and where it's enforced at the code level in <a href="https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/ElementHelper.php#L74" rel="nofollow noreferrer"><code>ElementHelper::setUniqueURI()</code></a></p>

CC BY-SA 3.0
2017-07-05T09:25:12.523Z
Ah right, so this is expected behaviour in a Structure section then.
Clive Portman
CC BY-SA 3.0
2017-07-05T18:29:45.277Z
Assuming the nested entries setting for that Structure is set to `{parent.uri}/{slug}`, then yeah, there's a good chance it'll always be unique (unless they're on the same level in the Structure).
Brad Bell
CC BY-SA 3.0
2017-07-06T08:28:30.823Z
In our case that's what we need, so thank you.
Clive Portman
CC BY-SA 3.0
2017-07-05T00:30:18.857Z
2017-07-05T00:30:18.857Z
Brad Bell
<p>I know Craft appends slugs with -1 if they already exist but I'm working on an app where the addition makes things awkward for us (we have to match the slug to a third-party service). I was under the impression they had to be unique but it seems you can edit an entry and change the slug to be the same as one that already exists.</p>

<p>This could be a good workaround for us, but I want to check whether it's a bug that's likely to get squashed or deliberate behaviour.</p>

<entrymodel><slug><entry-slug>
Do slugs absolutely have to be unique?
# Do slugs absolutely have to be unique?

(Asked by: username_0 on 2017-07-04)

I know Craft appends slugs with -1 if they already exist but I'm working on an app where the addition makes things awkward for us (we have to match the slug to a third-party service). I was under the impression they had to be unique but it seems you can edit an entry and change the slug to be the same as one that already exists.

This could be a good workaround for us, but I want to check whether it's a bug that's likely to get squashed or deliberate behaviour.

**Tags:** entrymodel, slug, entry-slug

---

## 1 answers

### Answer by username_1 on 2017-07-05. Score: 1 | Accepted answer

Technically it's a combination of the element's slug plus URI that is required to be unique (on a per-locale basis).

You can see the logic used and where it's enforced at the code level in [`ElementHelper::setUniqueURI()`](https://github.com/pixelandtonic/Craft-Release/blob/master/app/helpers/ElementHelper.php#L74)

> **Comments:**
> **username_0**: Ah right, so this is expected behaviour in a Structure section then.  
> **username_1**: Assuming the nested entries setting for that Structure is set to `{parent.uri}/{slug}`, then yeah, there's a good chance it'll always be unique (unless they're on the same level in the Structure).  
> **username_0**: In our case that's what we need, so thank you.  

---

