3

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 3

6

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!

5

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, ],

4
  • 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.
    – Sandwich
    Dec 11, 2017 at 16:56
  • Suggestion: you can drop in your html structure into the 404 template and add {% extends "_layouts/default.html" %}.
    – TRIM
    Dec 11, 2017 at 21:25
  • 1
    Sorry, 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.
    – Sandwich
    Dec 12, 2017 at 11:14
  • 1
    This makes no sense. Why do we have to turn dev mode off to see the 404? Aug 24, 2018 at 9:28
2
  1. Make sure you are in production mode in the .env file: ENVIRONMENT=production
  2. Make sure you have developer mode disabled in config/general.php file: 'devMode'=>false
  3. Make sure you have a 404.twig file in templates/
  4. 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.