-
Notifications
You must be signed in to change notification settings - Fork 1.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
404 page breaks translations #2022
Comments
Hi @mgeisler , can I work on this issue? I'm pretty new to open source contribution. |
Hi @aishwaryavenkatesan, you sure can! It would be wonderful to have someone look at this and help us come up with a good solution. Is the problem described okay in the issue? In short, the problem is that you always get the English 404 page. If you go to https://google.github.io/comprehensive-rust/hello-world.html, you see the side bar is in English. Compare to https://google.github.io/comprehensive-rust/es/hello-world.html, where the page and the sidebar is in Spanish. The problem is that https://google.github.io/comprehensive-rust/es/does-not-exist.html brings you out of the Spanish translation and back into the English original. I guess you're new to GitHub Pages, so I suggest you create a new empty repository on GitHub and play with them. Follow the Create a GitHub Pages site tutorial to get started. Use the <!doctype html>
<html lang="en-US">
<head>
<title>My test page</title>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>
I believe we should be able to detect the current URL ( At this point, the JavaScript could perhaps load the correct I'm not 100% sure about the last steps, but let us start by replicating the problem 😄 |
When you call
mdbook build
, you automatically get a404.html
page in the root of the output directory.Since we run
mdbook build
for each translation, we end up with a structure likeThe root
404.html
page is automatically used by GitHub Pages when a page cannot be found. Note that the URL doesn't change: the content of404.html
is simply returned to the browser.Now, this doesn't work well with our translations: you end up with the English
404.html
regardless of which translation you're currently viewing. We should fix this so that people get the correct version. Theoutput.html.input-404
setting is for that.Simply setting this is not enough: GitHub Pages doesn't know anything about the translation sub-directories, so it will continue to show people the root
404.html
page. I think we can fix this by injecting a bit of JavaScript into the404.md
file whichmdbook build
uses to generate the404.html
page.The text was updated successfully, but these errors were encountered: