Coder Social home page Coder Social logo

Comments (6)

Josh-Cena avatar Josh-Cena commented on September 27, 2024 2

Which 404 page gets served depends on your server. Most servers send /404.html whenever they receive a request to a nonexistent route. If you want to make it serve /fr/404.html, you have to configure your server to redirect all /fr/* to /fr/404.html. For example, check out https://github.com/facebook/docusaurus/blob/main/website/static/_redirects. This is going to be different for each server.

Maybe we can add this to the docs.

from docusaurus.

Fei927 avatar Fei927 commented on September 27, 2024 1

Yes we should document this. Not easy though because we can't write a full guide to all the existing hosting platforms. But we can give a few generic hosting recommendations.

I also want to give a few tips like setting caching headers for assets, leveraging Webpack persistent caching etc... Not sure where to put that, the deployment page is already quite messy and long. Maybe we need a whole sidebar category just for deployment?

I deployed docusaurus directly on my local machine without using a web hosting service.

What does "deployed" mean, you must be running something on your local machine. docusaurus serve CLI is a possibility but there are many others including Apache, Nginx, arnish, http-server, serve...

You should read the doc of the tool you use, and see if it's possible to redirect 404 reponses to the /<locale>/404.html file.

Note that docusaurus serve is not particularly the best option, as we document here: https://docusaurus.io/docs/deployment#self-hosting

I don't think we expose any way to serve the localized 404 page, but that could be an interesting thing to add automatically. This is the lib we use under the hood and it supports rewrites: https://github.com/vercel/serve-handler

If you use something else, you'd have to figure it out because we don't provide support for anything else than docusaurus serve.

OK, I understand. I use docusaurus serve. I will follow your advice and adjust my website according to the deployment section in the document. Thank you!

Maybe you can consider adding why you need a hosting service and the advantages of using a hosting service in the deployment document. This is just a suggestion.

Thanks for your reply!

from docusaurus.

Fei927 avatar Fei927 commented on September 27, 2024

Which 404 page gets served depends on your server. Most servers send /404.html whenever they receive a request to a nonexistent route. If you want to make it serve /fr/404.html, you have to configure your server to redirect all /fr/* to /fr/404.html. For example, check out https://github.com/facebook/docusaurus/blob/main/website/static/_redirects. This is going to be different for each server.

Maybe we can add this to the docs.

What should I do if I don't use a hosting service?

from docusaurus.

Josh-Cena avatar Josh-Cena commented on September 27, 2024

What are you using?

from docusaurus.

Fei927 avatar Fei927 commented on September 27, 2024

What are you using?

I deployed docusaurus directly on my local machine without using a web hosting service.

from docusaurus.

slorber avatar slorber commented on September 27, 2024

Yes we should document this. Not easy though because we can't write a full guide to all the existing hosting platforms. But we can give a few generic hosting recommendations.

I also want to give a few tips like setting caching headers for assets, leveraging Webpack persistent caching etc... Not sure where to put that, the deployment page is already quite messy and long. Maybe we need a whole sidebar category just for deployment?


I deployed docusaurus directly on my local machine without using a web hosting service.

What does "deployed" mean, you must be running something on your local machine. docusaurus serve CLI is a possibility but there are many others including Apache, Nginx, arnish, http-server, serve...

You should read the doc of the tool you use, and see if it's possible to redirect 404 reponses to the /<locale>/404.html file.


Note that docusaurus serve is not particularly the best option, as we document here: https://docusaurus.io/docs/deployment#self-hosting

I don't think we expose any way to serve the localized 404 page, but that could be an interesting thing to add automatically. This is the lib we use under the hood and it supports rewrites: https://github.com/vercel/serve-handler


If you use something else, you'd have to figure it out because we don't provide support for anything else than docusaurus serve.

from docusaurus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.