google / google/comprehensive-rust

404 page breaks translations

Open
#2,022 3 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Rust
Stars
33.4k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
10

Description

When you call `mdbook build`, you [automatically get a `404.html` page](https://rust-lang.github.io/mdBook/continuous-integration.html#404-handling) in the root of the output directory.

Since we run `mdbook build` for each translation, we end up with a structure like

```
/404.html
/da/404.html
/de/404.html
...
```

The root `404.html` page is automatically used by [GitHub Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-custom-404-page-for-your-github-pages-site) when a page cannot be found. Note that the URL doesn't change: the content of `404.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. The [`output.html.input-404`](https://rust-lang.github.io/mdBook/format/configuration/renderers.html#html-renderer-options) 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 the `404.md` file which `mdbook build` uses to generate the `404.html` page.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.