Skip to content
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

onBrokenLink ignores relative paths without file extension #3380

Closed
maksnester opened this issue Sep 1, 2020 · 3 comments
Closed

onBrokenLink ignores relative paths without file extension #3380

maksnester opened this issue Sep 1, 2020 · 3 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@maksnester
Copy link

maksnester commented Sep 1, 2020

🐛 Bug Report

Let's say you have a file Overview.mdx and reference it from another document.

[Overview](./Overview) <-- fails silenty at runtime (leads to 404)
[Overview](./Overview.md) <-- fails at build time correctly because there is an .md file not .mdx
[Overview](./Overview.mdx) <-- works great

Have you read the Contributing Guidelines on issues?

Sure

To Reproduce

  1. Use base path in your docusaurus config
  2. Create 2 files
  3. Reference one file from another without file extension

Expected behavior

That must be caught by the broken link handler.

(Write what you thought would happen.)

Actual Behavior

Links lead to 404 and I don't know about it until test it at runtime.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.62

Reproducible Demo

You can use docusaurus repo and reproduce locally.

Replace some relative link, for example here with a link without .md extension.

@maksnester maksnester added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 1, 2020
@slorber
Copy link
Collaborator

slorber commented Sep 1, 2020

Hi,

Will check this later.

Can you tell me which link should I put in the docusaurus 2 site you mentioned?
Preferably, if you can open a PR where the deploy preview does show a broken link, yet it was not catched at build time, it's the perfect repro to fix the bug for me :)

maksnester added a commit to maksnester/docusaurus that referenced this issue Sep 3, 2020
maksnester added a commit to maksnester/docusaurus that referenced this issue Sep 3, 2020
@maksnester
Copy link
Author

@slorber hi, sorry if it's not clear enough. The issue is about using relative link without the .md extension. It's actually mentioned here. But here is the PR anyway.

So if you open the Contribution page and click the "Getting started" link - it leads to 404. And it's not reported by broken links checker.

@slorber
Copy link
Collaborator

slorber commented Sep 3, 2020

Hey.

The problem is due to the hosting environment that add a trailing / automatically with a 302 redirect on initial load.

Due to this trailing slash, the relative link resolution is different:

If you navigate to the contributing page, the trailing slash won't be added by Netlify, and you'll find the "Getting started" link to resolve correctly.

I'd like to find a solution to this trailing slash problem but it's not clear what's the best solution yet, and it can be a breaking change for many sites

We'll track this issue here: #3372

In the meantime, the workaround is to avoid relative links if your hosting solution add this trailing slash. Docs should rather link using .md extensions and relative paths, as it will work fine with versioning, and also allow to navigate them through github interface.

@slorber slorber closed this as completed Sep 3, 2020
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

3 participants