Custom routes trigger broken links on build
See original GitHub issue🐛 Bug Report
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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
I have a custom plugin that adds /api/* routes through actions.addRoute(). This whole flow works great. You can see the code here: https://github.com/milesj/docusaurus-plugin-typedoc-api/blob/master/packages/plugin/src/index.ts#L208
However, when running yarn build, all the /api/* routes fail on broken links, like so:
- On source page path = /api/pipeline/class/Context:
-> linking to /api
-> linking to /blog
- On source page path = /api/pipeline/class/Monitor:
-> linking to /api
-> linking to /blog
- On source page path = /api/pipeline/class/ParallelPipeline:
-> linking to /api
-> linking to /blog
- On source page path = /api/pipeline/class/PooledPipeline:
-> linking to /api
-> linking to /blog
- On source page path = /api/pipeline/class/Routine:
-> linking to /api
-> linking to /blog
- On source page path = /docs/tutorial-extras/manage-docs-versions:
-> linking to /api
-> linking to /blog
- On source page path = /docs/tutorial-extras/translate-your-site:
-> linking to /api
-> linking to /blog
I’m not sure how to resolve this or if this is just an oversight.
The routes do appear in the .docusaurus/routes.js file, but not sure if that matters.
Have you read the Contributing Guidelines on issues?
Yes
Steps to reproduce
Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.
Creating a sandbox of this is too complicated. There are 2 ways to verify this though:
- Clone and checkout this PR which attempts to integrate and test the plugin: https://github.com/milesj/boost/pull/157
git clone git@github.com:milesj/boost.git
cd boost
git checkout typedoc
yarn install && yarn run build
cd website
yarn run build
- Install the
docusaurus-plugin-typedoc-apipackage and install it in a project: https://www.npmjs.com/package/docusaurus-plugin-typedoc-api
Expected behavior
The broken links check doesn’t fail on custom routes.
Actual behavior
The broken links check fails on custom routes.
I can bypass it for now by changing the onBrokenLinks setting but this isn’t ideal.
Your environment
- Public source code: https://github.com/milesj/boost/pull/157
- Public site URL: N/A
- Docusaurus version used: 2.0.0-beta.4
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Any node/yarn version
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS/Ubuntu
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
Got it working, thanks for checking.
I have some other things to discuss but I’ll create new issues for them.
great, looks like it also fixed the 404 issue on https://boostlib.dev/api 👍