Support custom header IDs in Markdown #329
Replies: 3 comments 5 replies
-
This is possible to enable using https://github.com/imcuttle/remark-heading-id Here’s a minimal example project using this remark plugin: https://stackblitz.com/edit/github-b6cdfq?file=astro.config.mjs |
Beta Was this translation helpful? Give feedback.
-
FYI this topic is now covered in the docs: https://docs.astro.build/en/guides/markdown-content/#markdown-plugins |
Beta Was this translation helpful? Give feedback.
-
Ignore thdoan's link above. I followed it, thinking the docs would have the latest way of doing things, but instead got sent on a wild goose chase. What the docs mention isn't relevant to what @sindresorhus was asking about, but @delucis's link is. In my case, the |
Beta Was this translation helpful? Give feedback.
-
Many Markdown parsers support an extension that allows explicitly setting the header ID using the
{#faq}
syntax:### Frequently Asked Questions {#faq}
It would be useful if Astro could support this too. It's common to need to set stable IDs that will not change even if the text changes.
Currently, we have to do this, which is ugly:
More info:
Update: I made my own plugin for this as one of the existing ones did too much and the other one stopped working. https://github.com/sindresorhus/remark-custom-header-id
Beta Was this translation helpful? Give feedback.
All reactions