Repository navigation
Duplicated whole page when accessing site by your-domain.com/index.html #9916
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
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
Description
Accessing docusaurus build by direct URL domain.com/index.html causes a duplicated page issue.
It looks like shipped docusaurus serve CLI implements a redirect from index.html > /. And it is a specific logic which are not presented in http servers by default.
Background
I'm trying to migrate docusaurus 2.4.3>3.1.1 and faced an issues with merge-request integration in GitLab pipelines. GitLab pipeline produces a docusaurus build artifact which can be accessible by URL's like
some-domain.com/-/repoName/-/jobs/12345/artifacts/build/index.html.
Attempts to omit index.html part, i.e. some-domain.com/-/repoName/-/jobs/12345/artifacts/build/ caused of HTTP404 error. Probably it's possible to have a workaround fix by adjusting redirect rules for my case. Anyway, duplicated content behavior looks like a bug.
Reproducible demo
- https://tlzj5p-9095.csb.app/index.html (not sure how long it will be accessible)
- https://docusaurus.io/index.html
Steps to reproduce
- install from scratch
npx create-docusaurus@latest my-website classic --typescript
cd my-website/
npm install
npm run build- run any http server to serve build over http (I'm using python http server to avoid side-effect redirects which shipped with
docusaurus serve)
cd build
python3 -m http.server 9005 Expected behavior
No duplicated content appears
Actual behavior
Whole site is rendered twice. Duplicated top-level menu and page content.
You can also observe this on https://docusaurus.io/index.html
Your environment
- Public source code: https://codesandbox.io/p/devbox/beautiful-archimedes-qdeo7
- Public site URL:
- https://tlzj5p-9095.csb.app/index.html (not sure how long it will be accessible)
- https://docusaurus.io/index.html
- Docusaurus version used: 3.1.1
- Reproduced locally using OSX 14.2.1 + NodeJS 18.18.2
Self-service
- I'd be willing to fix this bug myself.



Activity
slorber commentedon Mar 6, 2024
This has already been discussed here:
See my suggestions here: #9871 (comment)
You should serve pages by their canonical URLs. By default, this means serving them without the
.htmlextension.If this is a problem, there's often a "pretty URL" option on CDNs and static hosts you can turn on, otherwise you can use reverse proxy settings.
DmitryKorlas commentedon Mar 6, 2024
Thanks for your response and valuable feedback! Maybe it would be helpful to mention about new behavior at the migration guides. I followed the instructions step by step, but this behavior was unexpected.
DmitryKorlas commentedon Mar 7, 2024
Regarding my specific case with GitLab artifacts deployment for merge requests, I couldn't find the ability to implement a redirect on the GitLab side. GitLab integration requires an index.html file for viewing artifacts of MR.
I added a workaround trick to replace the URL on the client side. It looks messy, and I don't like it, but it resolved the issue. Perhaps it can be helpful to someone else:
slorber commentedon Apr 19, 2024
We'll try to fix this for V4 in #10059