Skip to content

Instantly share code, notes, and snippets.

@s-taylor
Forked from borekb/README.md
Created May 6, 2020 06:08
Show Gist options
  • Save s-taylor/206e5f4db0c4bd753a78b3e446dce3bc to your computer and use it in GitHub Desktop.
Save s-taylor/206e5f4db0c4bd753a78b3e446dce3bc to your computer and use it in GitHub Desktop.
How to link to headings in GitHub issues and pull requests

How to link to headings in GitHub issues and pull requests

If you have an issue comment / PR description on GitHub, it doesn't automatically get anchors / IDs that you could link to:

Screenshot 2019-07-11 at 13

What I like to do is to add a visible # character like this:

Screenshot 2019-07-11 at 13 42 21

It renders like this:

Screenshot 2019-07-11 at 13 32 03

Copy/paste-friendly Markdown snippet:

# Some heading <a href="#user-content-some-heading" id="some-heading">#</a>

Don't forget to add the user-content- prefix to href – that's how GitHub transforms custom IDs.


Alternatively, if you don't want the visible # character, you could also do this:

Screenshot 2019-07-11 at 13 45 29

It renders like this:

Screenshot 2019-07-11 at 13 46 32

The same URL as before can be used to link to this heading, e.g.:

https://github.com/borekb/example/issues/123#user-content-second-section

(You can use browser dev tools' Inspect element to find out the anchor.)

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