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.

Relative markdown links broken

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Both of these work correctly when navigating in the GitHub repo, but break in Docusaurus:

  • When trailingSlash: true, a markdown link [`api` file of a library](code_and_name_organization/#libraries) in /docs/design/functions.md incorrectly navigates to /docs/design/functions/code_and_name_organization/#libraries. It should navigate to /docs/design/code_and_name_organization/#libraries.

  • When trailingSlash: false, a markdown link [Language specification](lang) in /docs/spec/README.md incorrectly navigates to /docs/lang. It should navigate to /docs/spec/lang.

There are more links that fail in similar ways, these are just examples.

Adjusting these links in the markdown source is not an appropriate solution, since they work correctly in the GitHub interface where the files are being edited, so people will keep adding more similar links.

Reproducible demo

https://github.com/emlai/carbon-lang/tree/website/website

Steps to reproduce

  1. Configure trailingSlash as per description.
  2. Start dev server.
  3. Go to the corresponding page in the docs.
  4. Click on the corresponding link.

Expected behavior

Navigates to the correct path (see description).

Actual behavior

Navigates to an incorrect path (see description).

Your environment

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Sep 9, 2022

Closing because the current behavior is correct.

Maybe we should make this more visible? in an admonition tip?

I think it’s fine. https://twitter.com/ddbeck/status/1509925868021420042

1reaction
Josh-Cenacommented, Aug 25, 2022

Both are inevitable. Markdown links only work in one plugin so we definitely can’t only speak about that, let alone issuing an error. I (as a tech writer myself) firmly believe it’s important for you to see the bigger picture from the start especially when there’s no silver bullet. That’s the thing I find a lot of documentation annoyingly lack. I also know a lot of people who exclusively use absolute URL links, because URL links tend to be stable even when you move files around (you keep the slug or you add a redirect). It’s simply impossible to say “you must use Markdown links” without letting you know what you are actually doing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Markdown parent relative links broken (#7967) - GitLab FOSS
Markdown parent relative links broken. When a markdown link goes "up" (e.g., to ../foobar.md), the link deletes the ref from the URL.
Read more >
Relative image links broken in markdown files when using ...
The recent broken markdown images are due to a regression when turning on the New source browser experience via setting on Labs page....
Read more >
HTTP/s and relative link checker - Visual Studio Marketplace
Checks Markdown links for the presence of a country-code as you type and flags as a warning. Checks whether HTTP/s links or relative...
Read more >
Broken links in relative path mode on move/rename
Same problem applies to standard markdown links. 6 Likes. When moving a note to a different folder, the internal links are not updated....
Read more >
Relative link in readme broken if readme viewed automatically ...
Is this an expected behavior? What is wrong with my link? github · markdown · readme · Share.
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