We ran the same anchors through nine markdown renderers to find out why.
The link is plain markdown and works everywhere. The target is an element with a matching id, and that is the half that goes missing.
GitHub slugs every heading. Stock markdown-it and marked do not, so without a plugin the target never exists.
Pandoc, kramdown and Python-Markdown honor them. GitHub prints the braces and folds them into the slug instead.
An empty anchor with an id, on its own line above the spot, passed through every renderer we tested that allows HTML.
It adds a user-content prefix, then a page script maps your link back. Render the same HTML yourself and the link misses.
Put the file path before the fragment. GitHub resolves it, static sites need a rewrite, and npm pages need a full URL.
Search the rendered page for your id. Missing, prefixed, or encoded differently: that is your bug, not the link.
Lowercase id, empty anchor tag, blank line after it. Save curly braces for a parser you control.