facebook / facebook/docusaurus

yarn build error with "Docusaurus found broken links" after set baseUrl to "/docs/"

Đang mở
#6,294 24 bình luận 3 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).

### Prerequisites

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

### Description

yarn build error with "Docusaurus found broken links" after set baseUrl to "/docs/"

### Steps to reproduce

1. init
```sh
npx create-docusaurus@latest docs classic
```

2. build
```sh
cd docs
yarn build
...
[SUCCESS] Generated static files in build.
[INFO] Use `npm run serve` command to test your build locally.
Done in 69.04s.
PS D:\Document\github\docs>
```

3. change baseUrl from '/' to '/docs/'
```diff
# docusaurus.config.js
- baseUrl: '/',
+ baseUrl: '/docs/',
```

4. build

```
yarn build
...
[ERROR] Unable to build website for locale en.
[ERROR] Error: Docusaurus found broken links!

Please check the pages of your site in the list below, and make sure you don't reference any path that does not exist.
Note: it's possible to ignore broken links with the 'onBrokenLinks' Docusaurus configuration, and let the build pass.

It looks like some of the broken links we found appear in many pages of your site.
Maybe those broken links appear on all pages through your site layout?
We recommend that you check your theme configuration for such links (particularly, theme navbar and footer).
Frequent broken links are linking to:
- /docs/intro

Exhaustive list of all broken links found:

- On source page path = /docs/404.html:
-> linking to /docs/intro
```

5. check the links in files generated by build
```html
Docusaurus Tutorial - 5min ⏱️
```

### Expected behavior

the links in files generated by build should be like this
```html
Docusaurus Tutorial - 5min ⏱️
```

### Actual behavior

link in document should be like '/docs/docs/intro', but actually is '/docs/intro'

### Your environment

- Public source code: https://codesandbox.io/s/zealous-meadow-i63wc
- Public site URL: https://codesandbox.io/s/zealous-meadow-i63wc
- Docusaurus version used: 2.0.0-beta.14
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 94, Node.js v14.18.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): win10x64

### Reproducible demo

_No response_

### Self-service

- [ ] I'd be willing to fix this bug myself.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.