Working towards a better 404 "page not found" experience

I see many requests in my analytics for pages that don’t exist, examples:

  • URL has null character at the end (assuming a bug in a client/browser somewhere)
  • URL is missing final character(s) (copy and paste error)
  • URL has added text such as time (copy and paste error)

I’m looking to provide a better experience for my viewers and reduce the number of these error pages.

Is there a way partial URLs could be resolved?

For example, a valid URL path:

  • /2023/08/22/this-is-an-example

And invalid examples would be:

  • /2023/08/22/this-is-an-exampl
  • /2023/08/22/this-is-an-example[null]
  • /2023/08/22/this-is-an-example22:14

Can we resolve to the closest match? Or use the date to match the correct post?

Normally I would do this sort of thing via server config so not sure how to proceed.

  • Netlify: keen-bhaskara-f5872f
  • Jekyll

A good solution presented over at the Jekyll forum