Skip to content
All referenceStructure

Markdown Anchor Link

How to link to headings and sections within a markdown document. GitHub auto-generates heading anchors. Syntax and examples.

What is markdown anchor link?

Anchor links (also called internal links or jump links) allow you to link to a specific section within the same document. Markdown parsers automatically generate ID attributes for headings based on the heading text, which you can reference with a # in a regular markdown link.

Syntax

Link to a heading

The anchor is derived from the heading text: lowercase, spaces replaced with hyphens, punctuation removed.

In table of contents

Anchor links are the backbone of manually-written tables of contents.

Result

Heading → anchor conversion

Rules: lowercase everything, replace spaces with -, remove special characters except hyphens.

Result

Platform support

PlatformSupportedNotes
GitHubYesAuto-generates heading IDs
GitLabYes
ObsidianYesUse [[Page#Heading]] for cross-file links
NotionNoLinks to blocks available via share menu, not markdown
DiscordNo
SlackNo

Common mistakes

Wrong
[Link](#My Section)
Right
[Link](#my-section)

Heading IDs are lowercase with hyphens. "My Section" becomes #my-section, not #My-Section.

Wrong
[Link](#api-reference-(v2))
Right
[Link](#api-reference-v2)

Parentheses and most special characters are removed when generating heading IDs.

Tips for anchor link

1Use a TOC generator

Tools like MarkdownTools TOC Generator automatically create correct anchor links for all your headings, handling the ID conversion rules.

2Test in preview

Different markdown parsers handle special characters in heading IDs slightly differently. Always test anchor links in your target platform.

Frequently asked questions

Everything you need to know.

1

How do I link to a specific section in a markdown document?

Use a standard link with a # followed by the heading ID: [Section Name](#section-name). The ID is the heading text lowercased with spaces replaced by hyphens.

Related elements

Try it in the editor

Paste your markdown and see anchor link rendered instantly with professional themes.