Whenever I hit a non-existent page on a dev site, I only get Craft's native 404 page, not the one I have at /craft/templates/404.html
. The site has no routes. Any ideas why this might be?
3 Answers
Turns out the general.php
file had the following line (docs) in it:
'errorTemplatePrefix' => "_errors/"
Once I'd created the proper folder and files, all worked as expected.
Thanks, @CraftCMS Twitter person!
It's quite possible that you are in Dev mode. If you switch to false
, the 404.html may then be recognized…
Look at general.php, then change devMode
to false
.
// Dev environment settings
'dev' => [
'devMode' => true,
],
-
I certainly am in dev mode; I'm puzzled as to why custom 404 templates would be bypassed in dev mode though. Changing it to
false
doesn't make a difference.– SandwichDec 11, 2017 at 16:56 -
Suggestion: you can drop in your html structure into the 404 template and add
{% extends "_layouts/default.html" %}
.– TRIMDec 11, 2017 at 21:25 -
1Sorry, I don't see how that helps when the entire point of this question is that the 404 template isn't getting loaded in the first place.– SandwichDec 12, 2017 at 11:14
-
1This makes no sense. Why do we have to turn dev mode off to see the 404? Aug 24, 2018 at 9:28
- Make sure you are in production mode in the .env file:
ENVIRONMENT=production
- Make sure you have developer mode disabled in config/general.php file:
'devMode'=>false
- Make sure you have a 404.twig file in templates/
- This is not necessary, but ff you have all of the above and it still does not work, you can try adding this line in the config/general.php file:
'errorTemplatePrefix' => "404.twig"
You can also always go directly to the template and see if it is working. http://yourpath.test/404