Skip to content
FeaturesPricingBlogDownload
Home / Markdown syntax / Heading anchors and custom IDs

Heading anchors and custom IDs

A heading anchor is the ID that lets a link jump to a heading, as in [Setup](#setup). Markdown itself does not define anchors. The app that renders the file generates them from the heading text, and some apps also let you set a custom heading ID with {#id} after the heading. Because each app builds IDs its own way, a link that works on GitHub can fail elsewhere.

## Install on Linux

Jump to [Install on Linux](#install-on-linux).

How are heading anchors generated?

GitHub lowercases the heading text, replaces spaces with hyphens, removes other punctuation and markup, and adds -1, -2 and so on to repeated headings (GitHub Docs, checked November 2026). Other tools follow their own rules, and the differences show up with punctuation:

Heading GitHub Pandoc Markdown
## Install on Linux #install-on-linux #install-on-linux
## Version 2.0 notes #version-20-notes #version-2.0-notes
## Q&A #qa #qa

Pandoc keeps periods, underscores and hyphens, while GitHub drops periods. Obsidian takes another approach and links to a heading by its text, as in [[#Install on Linux]]. The table of contents guide walks through GitHub's rules in more detail.

How do you set a custom heading ID?

Put the ID in curly braces at the end of the heading line:

## Install on Linux {#linux}

See [the Linux steps](#linux).

A custom ID stays the same when you reword the heading, so links do not break. This syntax is an extension. Pandoc Markdown, kramdown (used by Jekyll), PHP Markdown Extra and Hugo support it. GitHub, Obsidian and VS Code's built-in preview do not, and they show {#linux} as part of the heading text.

How do you add an anchor where {#id} is not supported?

Use an HTML anchor on the line above the heading, where the renderer allows raw HTML:

<a id="linux"></a>
## Install on Linux

GitHub allows this form and notes that custom anchors do not appear in its outline (GitHub Docs, checked November 2026). Renderers that strip HTML remove the anchor, so the link has nowhere to go.

How do you link to a heading in another file?

Add the anchor after the file path:

[Linux install](docs/install.md#install-on-linux)

This works on GitHub and in VS Code. Static site generators often change .md links to page URLs when they build, so check the built site. The links page covers relative paths.

Which apps support each method?

App or spec Generated anchors {#id} <a id>
CommonMark Not defined No Raw HTML
GitHub Yes No Yes
VS Code preview Yes, GitHub style No Yes
Obsidian Links by heading text No Not used for links
Pandoc Markdown Yes Yes Raw HTML
Noteline In Word and PDF export No No

Why does my heading link not work?

  • The anchor is spelled the way one app builds it, and you are viewing it in another.
  • The heading was edited, so its generated ID changed.
  • Two headings have the same text, and the link needs the -1 suffix for the second one.
  • The anchor contains a space. Anchors use hyphens, so #install on linux is not a valid target.

Heading anchors in Noteline

In the desktop app, Word and PDF export build anchors from headings the way GitHub does, so a link such as [Setup](#setup) becomes a link that jumps inside the exported document. Check that each target heading exists before you export to PDF. The HTML export does not add IDs to headings, {#id} stays part of the heading text, and an <a id> tag is removed on export. While writing, the Table of Contents panel, Cmd+Shift+O on a Mac or Ctrl+Shift+O on Windows and Linux, lists the note's headings and jumps to the one you click.

Common questions

Are heading anchors case sensitive?

GitHub lowercases them, so write anchors in lowercase. Other renderers can differ, and lowercase is the safe choice everywhere.

Can I link to a heading that has emoji or accents?

Accented letters are kept by GitHub and Pandoc, so ## Résumé tips becomes #résumé-tips. Emoji and symbols are where apps differ most, and a custom ID avoids the guesswork where it is supported.

Do anchors work in Word and PDF files?

When the converter builds them, yes. Pandoc turns heading links into internal links in .docx and PDF output.

Noteline

Download Noteline↓See pricing→

Related

  • Markdown headings
  • Markdown links
  • HTML in Markdown
  • Bold, italic and strikethrough
  • How to make a Markdown table of contents with anchor links
  • Markdown syntax

A Markdown note editor with everything you need

We’re listening

Tell us what you need or what gets in your way. If something isn’t working, write to us any time.

contact@noteline.io→

Product

  • Download
  • Pricing
  • Features
  • Changelog

Learn

  • Markdown syntax
  • Use cases
  • Blog

Compare

  • vs Obsidian
  • vs Notion

Support

  • Help
  • Support
  • Privacy
  • Terms

© 2026 Notelinecontact@noteline.io