TOC component and header IDs

If you need to add a heading then it needs to be prefixed with heading-- you can find more information about that here Deep Linking to Headings (Anchors)

ids that are not prefixed like that will be stripped, regardless of what the id value is.

Headings with duplicate text are not currently supported - and have never been - in the TOC component. The component generates the id based on the text of the heading. So, two headings with the same exact text will get the same id.

There are no plans to patch this up in the component right now since automatic id generation is on our list of features for the next release of Discourse and we plan to address the issue of duplicate headings by adding the heading’s index to its id.

When we implement this in core, I think adding a prefix to the generated headings should be enough.

3 Likes