Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Github README anchor links

To create anchor links that jump down to different sections of a README (as in an interactive table of contents), first create a heading:
#Real Cool Heading

The anchor link for that heading is the lowercase heading name with dashes where there are spaces. You can always get the anchor name by visiting the README on and clicking on the anchor that appears when you hover to the left of the heading. Copy everything starting at the #:

Wherever you want to link to your Real Cool Heading section, put your desired text in brackets, followed by the anchor link in parentheses:
[Go to Real Cool Heading section](#real-cool-heading)

See! Easy: Go to Real Cool Heading section

#Real Cool Heading
This is a real cool heading with some real cool content.

Copy link

JAYD3V commented Nov 28, 2021


So I got it to work for VSCode extensions & CHANGELOGS, however, the HTML Attribute name fails to work in the VSCode Markdown-preview env.

This is the exact code I used, except that the comment was replaced with a bunch of entries.

[end of file](#eof)

<!-- markdown code between the link & anchor-tag -->

<a id="eof"></a>

# eof

If you want to see the actual formatting of the links in a working document, just install the VSCode extension recently released by Microsoft that allows developers to browse the contents of other developers published extensions: Browse Extension's Publish Contents.

You can probably find the links working in other extensions, but I can guarantee you that you will find working versions of the anchor-links located in the theme that I just published: JAYD3V.developers-dojo

Copy link

JAYD3V commented Nov 28, 2021

IDK if there has been a recent change to the parser since September 16th when the last comment was made in this thread, but the Markdown Preview parser seems to be working differently now as I get highlighting when I don't use the comment. Also I can't seem to get the Anchor links to work, is anyone successfully adding links in there or files in their VSCode extensions?


Response to my own post


There is another post I already made about it in this thread than shows a code snippet that works in VS-Code.

Copy link

Venryx commented Nov 28, 2021

I wonder if it matters whether one uses "id" vs "name" for the anchor link.

name has been working fine for me so far, but it's possible that id works in more programs/environments.

Copy link

JAYD3V commented Nov 30, 2021

I couldn't get name to work in V.S. Code, however, that was while testing the document using the VS-Code Markdown-preview extension that comes with the open source editor "out-of-the-box". When viewing a public extension — or extensions — from inside in the VS Code editor, using the extensions view, different software is used to parse and render the markdown. In other words, its really hard to tell what will work where, as there are several small markdown parsers out there, and no standardization among them that I know of. Would be nice to see someone make an attempt at standardization though.

Copy link

hseritt commented Jul 28, 2022

This does not seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment