Hey, welcome!
Is this syntax from kramdown or PHP Markdown Extra?
Discourse relies on MarkdownIt, which is based on CommonMark spec. It doesn’t support specifying a header ID.
It seems that they discussed it at some point: Anchors in markdown - Spec - CommonMark Discussion, but I don’t see any definitive conclusion.
However, Discourse generates anchor automatically.
You can see it here:
Essentially, you can expect those IDs:
h-{headingId}
(no post ID, no slug)h-{slug}-{headingId}
(no post ID)p-{postId}-h-{headingId}
(post ID, no slug)p-{postId}-h-{slug}-{headingId}
(post ID, slug)
E.g.:
If you prefer, you can still create an anchor manually with HTML, e.g., <a name="anchor_name"></a>
Additional resources –
If you need to generate a Table of Contents, there is this component for you: