Skip to content

Contextualize 404 page #9657

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

Merged
merged 97 commits into from
Apr 26, 2023
Merged

Conversation

benjaoming
Copy link
Contributor

@benjaoming benjaoming commented Oct 12, 2022

Update: This PR has gone through manual testing and is now ready for review.

Work history:

TODO

  • Version not found
  • Subproject page not found
  • Handle exception types with instanceof or similar
  • Remove too much debug logging
  • For "project page not found", we could try to suggest searching because {% url "elastic_project_search" project.slug %} affords us this option across Documentation project types?
  • Remember to remove errors/404/include_search.html in cases where searching isn't possible
  • Display correct request.path, not the one with _proxito_404_ in the path...
  • Add exception for "language not found"

What it looks like / scope

There are individual templates for different scenarios:

  • Page not found
  • Project not found (domain not found)
  • Subproject not found Scoped out, not currently covered by new unresolver
  • Translation not found
  • Version not found

Each case is detected, but we resort to only giving very basic suggestions and information. I made that choice to avoid discussing details at this stage.

Here is the 404 for a missing page:

image

And here is the 404 for a missing version:

image

Where to go now?

We can do more work to help users and documentation owners troubleshoot 404s. I think we just need to make small improvised changes to the 404s, as we get inspired from real life.

Brainstorming ideas for contextualized messages

Suggestions for "project page not found"

  • Inform people that project "xyz" does not contain this page, possibly because it got updated.
  • Look at the URL to understand if it's the /latest/ branch and tell the user that projects are updated over time, so a link to "latest" may change and that's a good thing. They can look for the page in older versions if the latest version doesn't contain a similar page.
  • Give people a search form for the project? That should be easy, right? <form method="GET" action="/en/{{ default_branch }}/search.html?> This needs a lot more context, i.e. "Is this a Sphinx project?" and "Which language are we looking at?". I don't find it feasible to implement.
  • Update: Instead of in-doc search, we can give people our ES powered search using the project scope 💯 🎉
  • A suggestion box for documentation developers

For "project not found"

  • Tell people that the URL is wrong
  • Project might have been deleted

For "subproject page not found"

  • Tell people that the URL is wrong
  • Tell people that the page in the subproject did not exist
  • That the page may have failed to build
  • That a translation may not be available (not ready)
  • A suggestion box for documentation developers

For "translation not found"

  • Something like "help translate this project to new languages" :)

For "readthedocs.org page not found"

  • The link you followed is broken
  • We will look into this if it's a technical error

References #2551


📚 Documentation previews 📚

@benjaoming benjaoming requested review from a team as code owners October 12, 2022 15:36
@benjaoming benjaoming marked this pull request as draft October 12, 2022 15:41
@benjaoming benjaoming mentioned this pull request Oct 25, 2022
@benjaoming
Copy link
Contributor Author

Note on the current state of the PR:

I'm still not looking for a code review :) But a general comment on the approach of contextualizing the Http404 exception is most welcome. I had the idea today and once I started implementing it, I saw a really nice pattern emerging.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love where are we going with this. 404 pages will be way better with these changes 💯

@ericholscher ericholscher linked an issue Nov 8, 2022 that may be closed by this pull request
@benjaoming
Copy link
Contributor Author

We are missing lots of tests :)

Going over the tests now, hadn't realized they were failing, was only testing on a small subset locally.

@benjaoming
Copy link
Contributor Author

Nice - the Django test client seems to have an option raise_view_exception that can test exception handling: https://code.djangoproject.com/ticket/18707#comment:14

@benjaoming
Copy link
Contributor Author

@stsewd ready for review - I added a POC of using raise_view_exception without adding a new bunch of test cases, but I think it's nice.

Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much simpler implementation 👍

Left some general suggestions

@benjaoming
Copy link
Contributor Author

Thanks for the great and detailed review @stsewd 💯

Will do some manual testing and get back ⏳

@benjaoming
Copy link
Contributor Author

@stsewd changes work locally, the failure in "checks" is unrelated.

@benjaoming benjaoming requested a review from stsewd April 21, 2023 18:30
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some information that will (should) always be available to templates, other than that I'm fine moving forward with this.

@benjaoming
Copy link
Contributor Author

Super happy to move forwards on this, thanks for all the feedback @stsewd 👍

I hope that anyone encountering a 404 in the future will quickly pitch in with improvements to texts and suggestions.

The new contents haven't been worked much with in the PR (although we did add some significant helpful texts and functions, as mentioned in the PR description). But it's great that we have now introduced a pattern that enables better 404 error handling with the option of using a targeted context, rather than unhelpfully broad messages.

@benjaoming benjaoming merged commit 2d0fd2a into readthedocs:main Apr 26, 2023
@benjaoming benjaoming deleted the contextualize-404 branch April 26, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve 404 pages
5 participants