Skip to content

Markdown Header Anchor Links do not work on page load #2399

@Noah-Silvera

Description

@Noah-Silvera

🐛 Bug Report

Each markdown header has a targeted anchor link which corresponds to a URL.
i.e. http:///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

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions