question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. Create a new site using npx @docusaurus/init@next init test-site classic
  2. yarn start
  3. 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

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:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
lex111commented, Mar 11, 2020

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 🤷‍♂️.

2reactions
Mauriceaccommented, Apr 29, 2021

I have this bug even after building.

Any workaround (other than refreshing, which effectively works)?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found