1

I am using Craft only for the blog section of my site. The rest is HTML.

How do I make my site's 404 page come up for errors in the Craft-blog section?

Do I use the errorTemplatePrefix?

Where does that go?

What to I put in there if Craft is above root and my page is mydomain.com/404.html

1

If your current 404 page is a static HTML page, I think the simplest solution would be to just copy your existing 404 HTML page into the craft/templates folder. Craft will display an HTML page just as easily as Twig code. Just make sure the file is named 404.html in your craft/templates folder.

If you make a change to the 404 page later, you would have to change it in two places, but that's really the only downside I can think of.

| improve this answer | |
  • I am just wondering how that will affect URL errors on Google. – Steve VH Apr 16 '15 at 16:33
  • SEO-wise it works the same to your current 404. Google would request a bad link like http://buildwithcraft.com/misspelled-docz/ and receive the 404 error and 404 page content back from the server. But the URL doesn't change to /404.html. It's stays the same as the requested URL. That's how an Apache server would deal with the error too. – Alex Roper Apr 16 '15 at 17:38
1

Can't think of a native way to do this — a few options come to mind, none of which are ideal.

  1. recreate your sites 404 page in your 404 template (should be able to just copy/paste for the most part).
  2. redirect to your site's 404 page from your 404 template (i.e. redirect 'craft/templates/404.html' to 'mydomain.com/404.html'). So in your 404 template you would have:

    {%  redirect '/404.html'  %}
    
  3. Reaching here, but you could also possibly include your 404 page in an iframe in your 404 template.

| improve this answer | |

Your Answer

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

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