-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Duplicated site content if navigating to */index.html documents directly #9552
Comments
Very interesting! My first thought is that this is an issue with the web server that we may be able to remedy but ultimately not our fault, but we would need to experiment. Is it possible that you put up such a site somewhere so we may take a look without setting it all up ourselves? |
We are running the site on our company internal network, so I cannot provide you with a public link.
const express = require('express');
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, 'build')));
app.get('/', async(req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(8080, () => {
console.log("Server successfully running on port 8080");
});
Note that it only occurs if you navigate explicitly to the |
I was able to further drill down on the issue by bluntly changing the generated html pages. <head>
<!-- cut for brevity -->
<script src="/assets/js/runtime~main.054d4dfc.js" defer="defer"></script>
<script src="/assets/js/main.b954583d.js" defer="defer"></script>
</head> Removing those two scripts from the html fixes the page so that it's only rendered once (probably breaking other things, but that is beside the point). It also seems to work fine, if I only remove the Diffing with a v2 build, the inclusion seems to have changed by making use of the Interestingly though, if I switch back to the v2 behaviour for a v3 build by moving the html around, it still breaks: <head>
<!-- cut for brevity -->
<link rel="preload" href="/assets/js/runtime~main.054d4dfc.js" as="script">
<link rel="preload" href="/assets/js/main.b954583d.js" as="script">
</head>
<body>
<!-- ... -->
<script src="/assets/js/runtime~main.054d4dfc.js"></script>
<script src="/assets/js/main.b954583d.js"></script>
</body>
<!-- Still duplicate page output --> Hope this helps in fixing the issue |
The problem is that you are accessing:
The problem is not the JS that we load, but the React hydration. For some reason it seems to fail to hydrate the existing markup when loaded from urls ending with Considering you should serve your pages through their canonical urls (not using You should configure your host so that Most static hosts support this out of the box, and otherwise it should be possible to configure it. This feature is usually called "clean urls" or "pretty urls". |
I can see how this is sufficient for most hosting setups, but it does break implementations that rely on the static content being served directly from file storage (like S3 or NFS), where you do not have a dedicated webserver sitting in front of every request. For example: We are running our Docusaurus site behind a LoadBalancer with a few simple rules to redirect clients to the correct pages inside a S3 bucket. This is a very cost-effective way to host it, as we can re-use a single LB for as many sites as we like. But we do need to provide a fully qualified URI as there is no implicit fallback to any default pages when targeting folders. I would even argue that for hosting a static site, the antipattern is to rely on implicit configuration over explicit URIs. And as the wording "clean urls" or "pretty urls" imply, this is more of an esthetical than a functional feature. |
@hofalk The point is: a path with |
That doesn't look cost effective to me. A cost-effective setup is having your LB being your CDN at the edge, eg Vercel Netlify Clouflare, or Cloudfront if you really want to stick to AWS tech
We rely on conventions and sensible defaults. This is not implicit: the url of If you want explicit URIs then you can use the If you want to serve docs with a path including an html extension, you can do that. This prevents the double-rendering issue you reported: ---
slug: /intro.html
--- In other words: docs have a default url, but you can override it if you want. It is your responsibility to be explicit if the defaults do not fit your taste. |
Except you cannot use Cloudfront for internal sites in private VPCs, as it will always use public IPs. If you know of a more cost-effective solution for that on AWS, please let me know, I am very interested.
What I meant was that the required configuration of the webserver to work with a production build of docusaurus/react is implicit. There is no URL for
This is unfortunately not a matter of taste for us. There is simply no way to direct an ALB to S3 for serving static content, without pointing it explicitly to the file that should be served, as there is no webserver in between which we could configure to serve the In any case: As you already made clear, that this regression from v2 will not be fixed, we will be moving away from the S3 setup of hosting the site towards hosting it through ECS. That will allow us to bundle it with a dedicated webserver which we can properly configure. Unfortunately it costs a little more than doing it through S3, but we think the docusaurus v3 update in general is worth it. And last but not least: Keep up all the good work! Loving docusaurus, especially the possibility to individually pick between mdx and md parsing that you introduced in v3. |
We'll try to fix this for V4 in #10059 |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Navigation to
index.html
of any page on a clean docusaurus 3.0 installation behind webserver/loadbalancer renders the page twice (e.g. site.xy/index.html or site.xy/blog/index.html). Navigation to the folder url works as expected (e.g. site.xy or site.xy/blog)I've experienced this issue behind an AWS NLB and was able to reproduce it with a clean docusaurus 3 installation on a local nginx webserver as well (see reproduce case below). We only experienced it after upgrading to 3.0 so I am assuming it's a 3.0 only issue.
The reproduce case is utilizing docker & docker-compose for this, but it should also work on any locally installed & configured webserver. The issue does NOT occur however on running a development server, neither does it occur wen using
npm run build && npm run serve
Reproducible demo
No response
Steps to reproduce
npx create-docusaurus@latest docusaurus-test classic --typescript
and change to installation dirdocusaurus-test
npm run build
./default.conf
for nginx:./docker-compose.yaml
service mounting the config and build:docker-compose up
localhost:8080/index.html
orlocalhost:8080/blog/index.html
Expected behavior
The page should only be rendered once
Actual behavior
Every page accessed directly through */index.html is rendered twice.
Browser console does not show any errors.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: