# Identische Titel führen zu identischen IDs und Ankerpunkten

**URL:** <https://meta.discourse.org/t/having-identical-titles-leads-to-identical-ids-and-anchors/270649>\
**Category:** Feature\
**Tags:** pr-welcome, disco-toc\
**Created:** [21. Juni 2023 um 08:00 UTC](https://meta.discourse.org/t/having-identical-titles-leads-to-identical-ids-and-anchors/270649 "2023-06-21T08:00:08Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [5. Juli 2023 um 19:14 UTC](https://meta.discourse.org/t/having-identical-titles-leads-to-identical-ids-and-anchors/270649/5 "2023-07-05T19:14:52Z")

</div>

> [@Canapin](#):
>
> Die Werte der Attribute basieren auf den Inhalten der Titel, sodass identische Titel identische `id`- und `data-d-toc`-Attribute haben:

Genau, das ist also keine inhärente Einschränkung von HTML (tatsächlich ist es ein Verstoß gegen die [Spezifikation](https://www.w3.org/TR/2015/WD-html51-20151008/dom.html#the-id-attribute), identische IDs in einem einzigen Dokument zu haben), sondern ein Fehler in der Theme-Komponente.

Ich vermute, [dieser](https://github.com/discourse/DiscoTOC/blob/main/javascripts/discourse/initializers/disco-toc-main.js#L50-L52)

```js
const suffix = slugify(h.textContent) || index;
const id = h.getAttribute("id") || slugify(`toc-${h.nodeName}-${suffix}`);

```

muss etwas wie folgt aussehen:

```js
const suffix = slugify(h.textContent) || '';
const id = h.getAttribute("id") || slugify(`toc-${h.nodeName}-${suffix}-${index}`);

```

---

_[View the full topic](https://meta.discourse.org/t/having-identical-titles-leads-to-identical-ids-and-anchors/270649)._
