Markdown Header Anchor Links do not work on page load
See original GitHub issue🐛 Bug Report
Each markdown header has a targeted anchor link which corresponds to a URL. i.e. http://<hostname>/docs/mobile/doc1#header1
If you click on the headers in the right sidebar when the documentation is loaded, the page scrolls to the header that is the anchor link target as expected.
But, if you copy a link to one of the headers with a anchor #
in it, and paste it into a new tab, the page does not scroll to the appropriate header on page load.
Have you read the Contributing Guidelines on issues?
yes
To Reproduce
- Create a new site using npx @docusaurus/init@next init test-site classic
yarn start
- Open http://localhost:3000/docs/doc1#admonitions
Expected behavior
The page doc1
is opened and scrolled to the admonitions header
Actual Behavior
The page doc1
is opened but not scrolled to the admonitions header
Your Environment
- Docusaurus version used: “@docusaurus/core”: “^2.0.0-alpha.48”, “@docusaurus/preset-classic”: “^2.0.0-alpha.48”,
- Chrome Version 80.0.3987.132
- Windows 10 Desktop
Reproducible Demo
This repo is an unmodified npx @docusaurus/init@next init test-site classic
but including for completeness
https://github.com/Noah-Silvera/docusaurus-anchor-links-bug
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to link to a named anchor in Multimarkdown?
In standard Markdown, place an anchor <a name="abcd"></a> where you want to link to and refer to it on the same page by...
Read more >Link to readme anchor does not scroll to the right heading
Observe that the page does not scroll to Custom HTTP Client , just stays at the top. What is the current bug behavior?...
Read more >Anchors | Confluence Data Center and Server 8.0
You can use anchors to enable linking to specific locations on a page, and they can be especially useful for allowing your readers...
Read more >Named Anchors & Markdown - DEV Community
The reason we have to add the anchor tag to the Header is that the Markdown spec doesn't automatically do it. Fortunately, many...
Read more >Links within the Same Page In Markdown (#Anchor Links)
The aim of this playbook is to define the use of an anchor link with Markdown, i.e. link within the same page. 1....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In dev mode, we do not use SSR, so this issue occurs. I do not think this is a serious bug, since there is no such thing in the production build. This may not be very comfortable, although it is unlikely that you will often use anchors links in dev mode 🤷♂️.
I have this bug even after building.
Any workaround (other than refreshing, which effectively works)?