Log in Sign up

How to set a custom 404 error message?

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


2 years ago, 6 replies   developers   404   Edit question

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 answer

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

Answered 2 years ago · Edit answer

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.

Answered 2 years ago · Edit answer

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

Answered 2 years ago · Edit answer

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.

Answered 2 years ago · Edit answer

Thanks for the suggestion :)

Answered 2 years ago · Edit answer