Skip to content

Fix #672: Prevent duplicate heading IDs in Docusaurus #679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2025
Merged

Conversation

scripthunter7
Copy link
Member

Fix #672

This PR fixes the issue where two headings could end up with the same ID in Docusaurus. By default, if two titles have the same text (e.g. ## Example and ### Example), Docusaurus’s slugger utility is smart enough to handle this in a stateful way by adding -1, -2 etc suffixes. However, if we manually override the ID (e.g. # Example {#custom-id}), collisions can occur. To prevent this, I wrote a very simple markdownlint rule and fixed the problematic cases. Additionally, this PR updates the markdownlint configuration to use the official markdownlint CLI tool, which properly supports custom rules.

Copy link

github-actions bot commented Apr 9, 2025

Preview was deployed to: https://pull-request-679.kb-adg.pages.dev/

Copy link

Preview was deployed to: https://pull-request-679.kb-adg.pages.dev/

Copy link

Preview was deployed to: https://pull-request-679.kb-adg.pages.dev/

@scripthunter7 scripthunter7 merged commit 5437321 into master Apr 21, 2025
2 checks passed
@scripthunter7 scripthunter7 deleted the fix/672 branch April 21, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle or prevent duplicated titles
5 participants