Skip to content

Conversation

m-aciek
Copy link
Contributor

@m-aciek m-aciek commented Sep 28, 2025

The default is /en/latest/. Our docs use /3/ for latest stable version documentation build. That way links and resources URLs will be correct in the generated 404 page, in the docs.python.org subdomain.

Closes #125895 if followed-up by nginx's (https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) directive config.

(This change doesn't require a news entry.)


📚 Documentation preview 📚: https://cpython-previews--139386.org.readthedocs.build/

The default is /en/latest/, but current docs hosting doesn't use this pattern. There's one 404 page for whole docs subdomain, so there's no need to provide a prefix per-version and/or per-language.
@m-aciek
Copy link
Contributor Author

m-aciek commented Sep 28, 2025

Doesn't break the RTD configuration: 404 in preview is still rendered correctly.

@hugovk
Copy link
Member

hugovk commented Sep 28, 2025

Will this work for other version builds such as https://docs.python.org/3.15/ and https://docs.python.org/dev/ ?

And for translations such as https://docs.python.org/pl/3/ and https://docs.python.org/pl/3.15/ ?

@AA-Turner
Copy link
Member

Indeed, this won't work properly. We would need to do this dynamically in docsbuild-scripts.

As such, I'll close.

A

@AA-Turner AA-Turner closed this Sep 28, 2025
@m-aciek
Copy link
Contributor Author

m-aciek commented Sep 28, 2025

We should set https://docs.python.org/3/404.html as a global 404 page (for whole subdomain). That way it will work for all versions.

Nice to have would be to set a 404 page per build, but:

  • that would (superfluously?) complicate the nginx configuration, and
  • without improved notfound_urls_prefix to support /{language}/{version}/ dynamically, we'd incorrectly link to current stable saying it's a version from build:
<li id="cpython-language-and-version">
  <a href="/3/index.html">3.15.0a0 Documentation</a> &#187;
</li>
  • we'd load JS and styles from current stable version rendered with Sphinx 8.2.3; that potentially could cause incompatibilities, when 404 was rendered with an old Sphinx version (e.g. Sphinx 2.4 from Python 3.9); for example:
    <script src="/3/_static/documentation_options.js?v=048d8b21"></script>
    <script src="/3/_static/doctools.js?v=9bcbadda"></script>
    <script src="/3/_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <script src="/3/_static/sidebar.js"></script>

I think having a global 404 with English latest stable link (without the nice to have) is just fine, or at least fine until we figure out how to improve it.

@m-aciek
Copy link
Contributor Author

m-aciek commented Sep 28, 2025

It can be tested locally e.g. this way:

cpython % cd Doc
Doc % make html
…
Doc % cd build
build % mv html 3  # to imitate directories layout on the production server
build % python -m http.server  # browse to http://localhost:8000/3/404.html
Zrzut ekranu 2025-09-28 o 22 50 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: sphinx-notfound-page doesn't show nicer 404 page
3 participants