Skip to content

How to customize heading anchor links instead of automatically generating them based on heading text? #2819

Answered by HiDeoo
yangxuan74 asked this question in Q&A
Discussion options

You must be logged in to vote

As specified in the Markdown Cheat Sheet from The Markdown Guide linked in the documentation, custom heading IDs are part of the extended syntax which is not supported out of the box by all Markdown applications. This is the case for Starlight but Starlight and Astro supports adding 3rd-party plugins for Markdown & MDX.

In this case, you would need to install a plugin like remark-custom-heading-id and add it to your configuration:

import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import { remarkHeadingId } from "remark-custom-heading-id";

export default defineConfig({
  integrations: [starlight({ title: "My Docs" })],
  markdown: {
    remarkPlugins: [

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by delucis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants