0

I'm having issues with my 404 page template not showing.

I set up a single to manage my 404 page content using the method Brandon suggests in this post

I can go directly to the page at http://example.com/404, but if I go to an actual bad url, I get a generic Craft Page Not Found error.

I don't have any routes set up, dev mode is not enabled, and my Show full exception views when Dev Mode is disabled preference is unchecked.

Not sure if it makes a difference, but my index template looks like this:

{% set path404 = '404' %}
    {% if entry.type is defined %}
        {% switch entry.type.handle %}

           {% case "redirect" %}
               {% redirect entry.redirect.url 301 %}

           {% case "news" %}
               {% include ['pages/news', path404] %}

           {% default %}
               {% include ['pages/page', path404] %}

        {% endswitch %}
    
    {% else %}
        Entry is not defined.
{% endif %}

And my 404 template:

{% if entry is not defined %}
    {% set entry = craft.entries.uri('404').first() %}
{% endif %}

{% extends "_layout" %}
{% block content %}

 ... page layout...

{% endblock %}

I've done this before on other sites, and it works fine, so I'm sure it's something simple that I'm doing wrong, but I just can't see the error.

1
  • This should work. Are you sure your 404.html is a direct child of the "templates" folder? – Andreas Jun 8 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.