Blot

How to set a custom 404 error message?

I would like to check if we can set custom 404 messages? Thank you.

Asked 4 years ago Edit
6 replies

You should be able to edit the content of your template's error.html page in your template, which is the page displayed for 404s on your site.

4 years ago Edit

It seems the error.html page renders the error message from{{error.message}}, and I'am looking for the way to customize that variable

4 years ago Edit

Just replace {{error.message}} with whatever you'd like to see, e.g. 'This page is missing'. You don't need to customize the variable to achieve the result you're after.

4 years ago Edit

Can {{error.message}} be used for another error? Or is it just used for 404 errors?

4 years ago Edit

There are other types of error (e.g. 500) which affect the value of {{error.message}} but they do not vary greatly. You can review the source code for the error handling middleware.

My recommendation again is to just replace {{error.message}} with whatever you'd like to see.

4 years ago Edit

Thanks for the suggestion :)

4 years ago Edit

Your reply