Skip to content

Generate a custom 404 page #174

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

Closed
mbostock opened this issue Nov 15, 2023 · 2 comments · Fixed by #205
Closed

Generate a custom 404 page #174

mbostock opened this issue Nov 15, 2023 · 2 comments · Fixed by #205
Assignees
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

And maybe this could handle redirects for trailing slashes as described in #171.

@mbostock mbostock added the enhancement New feature or request label Nov 15, 2023
@mbostock mbostock modified the milestones: General availability, Future Nov 15, 2023
@Fil
Copy link
Contributor

Fil commented Nov 15, 2023

Yes, we can handle #171 with the following script in 404.html, either by shooting in the dark when the requested URL ends with a /:

if (location.pathname.endsWith("/")) {
  location.replace(location.pathname.slice(0,-1) + ".html");
}

Or by listing only the relevant URLs:

if (["/javascript/"].find((dir) => location.pathname.endsWith(dir)) {
  location.replace(location.pathname.slice(0,-1) + ".html");
}

We could build 404.html from a custom 404.md, if present.

@Fil
Copy link
Contributor

Fil commented Nov 15, 2023

A --base (#42) will be useful for the built 404.html, as it might be served from different depths in /the/request/path/hierarchy.

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

Successfully merging a pull request may close this issue.

2 participants