How to set a custom 404 error message?
I would like to check if we can set custom 404 messages? Thank you.
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.
Answered 2 years ago · Edit answerIt seems the error.html page renders the error message from{{error.message}}
, and I'am looking for the way to customize that variable
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.
Can {{error.message}}
be used for another error? Or is it just used for 404 errors?
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.