You still haven’t answered my question. Telling us that it isn’t working is not helpful. We have no idea what isn’t working, how it is failing, etc. See Requesting Help.
In general…
Pure markdown
In your site configuration, enable markdown attributes for block level elements (blockquotes, fenced code blocks, headings, horizontal rules, lists, paragraphs, and tables).
[markup.goldmark.parser.attribute]
title = true # default is true
block = true # default is false
Then in your markdown you can do:
This is a [link](#reference) to a block level element on the page.
This is the reference.
{#reference}
Markdown mixed with HTML
In your site configuration, allow HTML in content:
[markup.goldmark.renderer]
unsafe = true # default is false
This is safe if you control the content.
Then in your markdown you can do:
This is a [link](#reference) to a block level element on the page.
<div id="reference">
This is the reference.
</div>