Skip to content

CXX-3195 add 404 page with automatic redirection #1302

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 1 commit into from
Dec 13, 2024

Conversation

eramongodb
Copy link
Contributor

@eramongodb eramongodb commented Dec 12, 2024

Resolves CXX-3195. Precursor changes to CXX-2745 to gracefully handle API doc pages which are no longer present in the latest API documentation, such as in #1301.

Implemented according to GitHub Pages Docs using a Hugo-generated custom 404 homepage as a template which was stripped down to its current state with site-wide contents preserved (e.g. content security policy, stylesheets, site visit tracker, etc.).

404 and redirection behavior has not yet been tested with GitHub Pages deployment. Behavior will be tested and validated after deployment with followup PRs if necessary.

GitHub Pages supports using a custom 404 error page located at /404.html relative to the root directory. This PR proposes a 404 page which waits 5 seconds before redirecting users (with page history preservation, unlike /api/current page redirects) to either the current API docs homepage for URLs under /api, or to the website homepage for all other URLs. It is possible this behavior does not work as intended with GitHub Pages depending on how it implements the 404 error page (does it "redirect" to /404.html, thus window.location is always the 404 page, not the original link? does it "substitute" the contents of /404.html using the original link?). Regardless, the proposed 404 error page is expected to automatically redirect the user instead of the current status quo of GitHub Pages' default 404 page with no redirection.

@eramongodb eramongodb requested a review from kevinAlbs December 12, 2024 19:10
@eramongodb eramongodb self-assigned this Dec 12, 2024
@kevinAlbs kevinAlbs requested review from rcsanchez97 and removed request for kevinAlbs December 12, 2024 19:50
@eramongodb eramongodb merged commit 24e9486 into mongodb:gh-pages Dec 13, 2024
@eramongodb eramongodb deleted the cxx-3195-pages branch December 13, 2024 15:01
@eramongodb
Copy link
Contributor Author

Confirmed 404 automatic redirection works as intended with the deployed pages.

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

Successfully merging this pull request may close these issues.

2 participants