Search code examples
htmltfsmarkdown

How to set an anchor in Markdown File


I want to set an anchor in a .md file. The file is in the Team Foundation Server but the tag <a name="anchor"></a> does not work. Are there any other possibilities to set an anchor in a .md file?

I already tried the following:

Link to an anchor

[Question 22](answers.md#answer22)

Setting an anchor

<a name="answer22"></a> This is an answer for Question 22

The result is that clicking on "Question 22" the file answers.md is opened successfully but isn't "hopping" to Question 22. Furthermore the tag <a name="answer22"><a/> doesn't seem to be recognized as Code in the md. File in the TFS. If I open the File answer22.md and look at the preview (in TFS you can switch between "contents", "preview", "history" etc.) the tag is not hidden and you can see it in the preview as if it is just plain text.


Solution

  • As stated in Microsofts basic Markdown guidance, anchors are generated for every heading.

    Just place your answer below a heading.

    questions.md

    [Question22](./answers.md#answer-22)
    

    answers.md

    ## Answer 22
    
    The answer is 42