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

navigation to '/index.html' with a static web server duplicates the page's content. #9871

Closed
6 of 7 tasks
bishabosha opened this issue Feb 20, 2024 · 2 comments
Closed
6 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)

Comments

@bishabosha
Copy link

bishabosha commented Feb 20, 2024

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

when using a static web servers, such as GitHub pages, or static-web-server, and using the theme from preset-classic, navigation to the url /index.html will render the page twice, where the second is appended as a child to the end of the __docusaurus div. This even affects the official Docusaurus website at https://docusaurus.io/index.html

Reproducible demo

https://github.com/sbt/website

Steps to reproduce

  1. check out commit 710848 of sbt/website
  2. follow the steps in README.md (Docusaurus section) (i.e. yarn install, then yarn run build)
  3. use a static web server to serve the generated build directory, I use static-web-server and port 8080
  4. in a browser, such as Google Chrome, navigate to localhost:8080/index.html
  5. observe the duplication of the index page content.

Expected behavior

It should render identically to / route, i.e. no duplication.

Actual behavior

the page's content is duplicated as the last child of the div with id __docusaurus.

Screenshot 2024-02-20 at 14 11 02 Screenshot 2024-02-20 at 14 11 27 Screenshot 2024-02-20 at 14 12 17

Your environment

  • Public source code: sbt/website@7108487
  • Public site URL: https://www.scala-sbt.org/index.html
  • Docusaurus version used: 3.1.0 (also tested with 3.1.1)
  • Environment name and version: Chrome Version 121.0.6167.184 (Official Build) (arm64)
  • Operating system and version: macOS Sonoma 14.2.1 (23C71)

Self-service

  • I'd be willing to fix this bug myself.
@bishabosha bishabosha 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 Feb 20, 2024
@slorber slorber added closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed status: needs triage This issue has not been triaged by maintainers labels Feb 20, 2024
@slorber
Copy link
Collaborator

slorber commented Feb 20, 2024

This is a duplicate of #9552

See my answer here: #9552 (comment)

Pages should be served through their canonical urls, and by default, the canonical urls we define for pages do not have a .html extension.

Serving the same page from multiple urls (/xyz, /xyz/, /xyz.html, /xyz/index.html, and any other 200 reverse proxy you set up) is likely to cause troubles.

If this is a problem for you, you should either:

  • configure your host to redirect from /xyz.html to the canonical url /xyz)
  • use slug: "xyz.html" to define the html url as the canonical one

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
@bishabosha
Copy link
Author

Thank you for the quick response

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 closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)
Projects
None yet
Development

No branches or pull requests

2 participants