1

I'm trying to create fragment anchors to use for link destinations in GitHub markdown. I'm trying to avoid embedding HTML elements since best-practice markdown is to avoid inline HTML.

I'm not talking about heading anchors (though if a heading has non-letter characters, getting auto-generated heading links to work can be a trial-and-error headache). I need to have anchors for arbitrary locations in a .md file.

I've come across GitHub documentation for link reference definitions, but that documentation doesn't really explain clearly how to create an anchor. I tried following Example 168 of creating a link reference without specifying a destination, but that doesn't create an anchor; it just creates a "road to nowhere", so to speak.

What's the best option?

Peter Constable
  • 2,707
  • 10
  • 23
  • You would have to use HTML. Only headers give you a markdown way to generate an anchor automatically. – matt May 28 '20 at 01:03

1 Answers1

1

Markdown doesn't support custom anchors out-of-the-box (however, some markdown flavors may do) so you have to use HTML.

Create an anchor:

<a name="location"></a>

Refer to this anchor:

Take me to something [custom](#location)
Bandantonio
  • 816
  • 1
  • 7
  • 19