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

Broken link detection in development #6998

Open
4 of 7 tasks
YOU54F opened this issue Mar 25, 2022 · 6 comments
Open
4 of 7 tasks

Broken link detection in development #6998

YOU54F opened this issue Mar 25, 2022 · 6 comments
Labels
domain: dx Related to developer experience of working on Docusaurus sites feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@YOU54F
Copy link

YOU54F commented Mar 25, 2022

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

Hello,

I am currently working through our https://docs.pact.io site and we had a number of broken links.

We have now set onBrokenLinks to true, which causes the build the fail. 👍🏾

however as noted in the docs

The broken links detection is only available for a production build (docusaurus build).

I would love to give my contributors earlier feedback, during development as per to onDuplicateRoutes

By default, it displays a warning after you run yarn start or yarn build.

when they run yarn start.

I haven't looked at the codebase, to see the rational for this only being applicable for production builds at the moment.

Thanks in advance and also for the great project!

Reproducible demo

No response

Steps to reproduce

  1. Have a broken link in your docusaurus site
  2. set onBrokenLinks to error
  3. run yarn start and user is not notified there are broken links
  4. run yarn build and build fails with user notified of broken links

Expected behavior

  1. Have a broken link in your docusaurus site
  2. set onBrokenLinks to error
  3. run yarn start and build fails with user notified of broken links
  4. run yarn build and build fails with user notified of broken links

Actual behavior

  1. Have a broken link in your docusaurus site
  2. set onBrokenLinks to error
  3. run yarn start and user is not notified there are broken links

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@YOU54F YOU54F 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 Mar 25, 2022
@Josh-Cena Josh-Cena added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. and removed 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 Mar 25, 2022
@Josh-Cena
Copy link
Collaborator

I think it's possible, but there'll be false-positives since we can't know if a link is linking to a static asset (we detect that by making FS calls). Still it's mostly fine IMO

@YOU54F
Copy link
Author

YOU54F commented Mar 25, 2022

Thanks @Josh-Cena

🤔 Good point about the static asset linking. False positives are less than ideal, maybe we might set it at warn level in our configuration so at least the user gets feedback, and can make a decision either way.

We may want additional information in an error message to state something to that effect, and the user can run the build check to determine if it is a false positive or not. I don't know if that is just an extra inconvenience.

Would you think we would we better applying this as a boolean with a new property such as onBrokenLinksDevelopment and it honours the level set by onBrokenLinks

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Mar 25, 2022

Yes, that's exactly how I would design it: give some feedback, but also remind users about false-positives. @slorber Do you think this sounds reasonable?

@YOU54F
Copy link
Author

YOU54F commented Mar 25, 2022

It seems like this was requested on the canny feature request board as well, my apologies for not checking!

https://docusaurus.io/feature-requests/p/onbrokenlinks-in-development.

Yes this is a technical limitation.
The broken link checked actually render the pages to collect the rendered links and compare against the routes.
This is not ideal because it fails too late in the build process and the feedback loop is slow. However it's also quite reliable because it works for any links, including paths that are created using JS (ie not statically analyzable).
We should find a way to provide a simpler broken link detection algo that would be less reliable but that could be faster

@Josh-Cena Josh-Cena changed the title onBrokenLinks option:- enable for development builds? Rough broken link detection in development Mar 26, 2022
@Josh-Cena Josh-Cena changed the title Rough broken link detection in development Broken link detection in development Mar 26, 2022
@yzeng25
Copy link

yzeng25 commented Mar 28, 2022

Hi @YOU54F , I've had the similar broken link issues. Instead of completely relying on Docusaurus to solve them, there are third-party tools designed for broken link checks. I tried all of them when I was maintaining a document website, and the third tool is more handy than the other two.

https://validator.w3.org/checklink
https://www.brokenlinkcheck.com/
https://www.drlinkcheck.com/

@YOU54F
Copy link
Author

YOU54F commented Mar 28, 2022

Hi @YOU54F , I've had the similar broken link issues. Instead of completely relying on Docusaurus to solve them, there are third-party tools designed for broken link checks. I tried all of them when I was maintaining a document website, and the third tool is more handy than the other two.

https://validator.w3.org/checklink https://www.brokenlinkcheck.com/ https://www.drlinkcheck.com/

Awesome dude, checking these out, as especially external links may die over time and not necessarily at fault to the creator of a PR. Running an check via another tool, as a cron job with a report, and an issue raised in the respective repo to resolve, might be enough of a call to action to fix 👍🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: dx Related to developer experience of working on Docusaurus sites feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

3 participants