Tuesday, March 24, 2026

markdown anchor tags and links, for AI code

"Markdown" files are becoming a primary format for "AI enabled coding" workflows.

Also for documenting what is done.

Usually there are many files, some could be large, so being able to reference to part of the file is useful.

Since Markdown is based on HTML, anchor tags are supported, and even easier to use.


Learn how Markdown Links work. Welcome to the world of Markdown Links… | by Jochen Gererstorfer | inhalt | Medium


html - How to set an anchor in Markdown File - Stack Overflow

Named Anchors & Markdown - DEV Community


AI Overview

Anchor tags in Markdown allow you to link directly to a specific section within another file by combining the file path with a heading ID (anchor).

How it Works
  1. Identify the Anchor: Most Markdown renderers (like GitHub or VS Code) automatically generate anchors for headings by converting the text to lowercase and replacing spaces with hyphens.
  2. Combine Path and Anchor: To link to a section in a different file, use the format: [Link Text](path/to/file.md#anchor-name)
Assume you have two files in the same folder: README.md and setup.md.
In setup.md:
markdown
# Installation Guide

## Step 2: Configuration
This is the section we want to link to.
The auto-generated anchor for the heading above is #step-2-configuration.
In README.md:
To link to that specific section from your main file:
markdown
Check out the [Configuration Section](setup.md#step-2-configuration) for more details.
Advanced Usage
  • Custom Anchors: If your renderer doesn't auto-generate IDs or you want a shorter link, you can manually insert an HTML anchor tag before a heading: <a id="custom-id"></a>. Link to it using setup.md#custom-id.
  • Case Sensitivity: Most platforms require the anchor part (after the #) to be all lowercase.
  • Special Characters: Punctuation in headings is typically ignored when generating the ID (e.g., ## Setup! becomes #setup)

No comments: