диета при панкреатите

Are You Losing Readers From Your 404 Page?

404 ErrorNo matter how much time and tedious effort we put into making sure all of our links work, and go where they are suppose to, we can’t always control incoming links. Maybe a search engine is still indexing a page you deleted or renamed long ago, or someone is errantly linking to one of your articles. Regardless of how it happens, dead or errant links come with the territory.

When a user clicks on a dead or errant link one of two things usually happens. Either they get the default browser 404 Error Page or they may get a generic 404 Error Page that says something like:

Error 404 - Not Found

Neither of these options are optimal as they will likely result in the user quickly leaving to find the information they need elsewhere. You just lost a user who could potentially be a loyal reader and income generator.

No need to worry though, by creating a custom, more helpful, 404 Error Page you can encourage readers to look further than the standard error page. And in the process you may be able to convert them into a loyal reader. Here is a quick guide on how to edit or create your own custom 404 Error Page in WordPress.

Find Your 404 Error Page

If you are using one of the many standard WordPress themes, you will likely already have an existing 404 Error Page of some kind. However, this is not always the case. Here is how to check to see if you have an existing 404 Error Page with your template.

Login to your WordPress Admin and navigate to “Presentation” > “Theme Editor”. On the right had side you will see a list of all of the page associated with your theme (Stylesheet, Header, Footer, Main Index, etc.). If you have an existing 404 Error Page it will probably be listed as 404 Template, 404 Error, 404.php, or similiar. If you do not have any of these files do not worry, I will go over how to create your own 404 Error Page in the next section.

Create A 404 Error Page

If your theme currently does not have a 404 Error Page, one can be easily created by following these steps.

1. Create a blank file and name it 404.php
2. In your Theme Editor section of your WordPress Admin (WordPress Admin > Presentation > Theme Editor) click on your “Main Index Template” file.
3. Copy the contents of your “Main Index Template” file to your new 404.php file
4. Remove “The Loop” and any other unnecessary code. Your “Loop” should look something like this.

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(''); ?></p>
<?php comments_template(); ?>
<?php endwhile; ?>

Once you have removed “The Loop” and all other non essential code you should be left with something like this. (Note: This is a simplified version but will give you an idea)

<?php get_header(); ?>
<div id="content">
This is where your “Loop” content was
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

5. Add some sort of test message (ie. This is a sample 404 page) where your “Loop” used to be.
6. Save this 404.php file and upload to your theme directory.
7. Verify your new 404 Error Page is working by trying to access a page on your site that doesn’t exist (www.yourdomain.com/AverageJoeBloggerIsTheCoolest/).

You now have a blank 404 Error Page that you can customize and that will match the rest of your theme.

Edit Your 404 Error Page

Whether you already had an existing 404 Error Page or just created one using the steps above, it’s now time to make changes and customize the error page to include more helpful information that will encourage readers to hang around your site for a bit longer.

If your not still logged into your WordPress Admin, then re-login and navigate to: WordPress Admin > Presentation > Theme Editor > 404 Template

Your file should look something like what I have here.

<?php get_header(); ?>
<div id="content">
Custom 404 Message Goes Here
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Now just have a bit of fun with it and use your creativity. At the very least you should write a custom message with some helpful information on how else your lost reader might be able to find what they are looking for.

Find Some Inspiration

If you need some inspiration take a look at my 404 Error Page or just use this link www.yourdomain.com/AverageJoeBloggerIsTheCoolest/ and replace “www.yourdomain.com” the domain of your favorite blogger. Here are a few to get you started.

If you enjoyed reading Average Joe Blogger why not subscribe to my RSS Feed or get it delivered directly to your email inbox.

26 Responses to “Are You Losing Readers From Your 404 Page?”

  1. MyAvatars 0.2 Steven Snell |

    Nate,
    That’s a good, simple explanation of how to create a 404 page for WordPress. Thanks.

  2. MyAvatars 0.2 Jayne |

    Great explanation! I hadn’t gone to the trouble to do this, but I will now!

  3. MyAvatars 0.2 Word Hugger |

    You can also try redirecting the 404 to the index, as I have seen on a lot of sites. I don’t know which would be better for getting returning visitors.

  4. MyAvatars 0.2 Nate (Average Joe Blogger) |

    Redirecting (or displaying) the index of the blog is the default action for WordPress if no 404 page is available to display. The reason you see this on quite a few sites is mostly because they haven’t taken the time create a 404 page.

    In my opinion, just redirecting to the index is bad idea. If a user clicks on a link, they are expecting to be taken to a specific page or post. If that page cannot be found, redirecting them to the index page, with no explanation, will only confuse them and likely result in them just leaving your site.

  5. MyAvatars 0.2 Create a Custom 404 Error Page for Your Blog |

    […] you are a WordPress user (as the majority of ProBlogger readers are) I would suggest you look at a post on 404 pages that Average Joe Blogger posted on the topic a few days back which reminded me to fix my own 404 […]

  6. MyAvatars 0.2 Dan |

    Fantastic 404 page. Thanks!

    There’s a tiny typo in the second sentence…the “is” is missing. Just thought you’d wanna know.

  7. MyAvatars 0.2 Nate (Average Joe Blogger) |

    Dan: Actually, that part of the sentence worked basically the same with or without the “is” (assuming we are talking about the same thing). I think the main problem (confusion) is that it just wasn’t worded very well.

    I changed the wording from past tense to present tense and I think it flows a little better. Thanks for pointing it out.

  8. MyAvatars 0.2 dave |

    Nice blog, found your site via problogger.net.

    I’d be careful about having adsense on your 404 page.

    You have to login to find this page - https://www.google.com/adsense/static/en_US/LocalizedTerms2.html

    5 Prohibited Uses. You shall not, and shall not authorize or encourage any third party to: … (v) display any Ad(s), Link(s), or Referral Button(s) on any error page, on any registration or “thank you” page (e.g., a page that thanks a user after he/she has registered with the applicable Web site), on any chat page, in any email, or on any Web page or any Web site that contains any pornographic, hate-related, violent, or illegal content;

  9. MyAvatars 0.2 Nate (Average Joe Blogger) |

    Dave: That’s a good point that I hadn’t considered. Thanks for bringing it to my attention and thanks for stopping by.

  10. MyAvatars 0.2 karyn |

    Wow! You’re explaination made this very simple and easy for a noob like me to do. thanks much, and I’ll be reading your blog regularly. ( found you through problogger too)

  11. MyAvatars 0.2 Small Business Blogging Speedlinking - Vol. 2 | Prevail PR |

    […] Are You Losing Readers From Your 404 Page? […]

  12. MyAvatars 0.2 Nate (Average Joe Blogger) |

    karyn: Thanks for stopping by. I’m glad this article was able to help you.

  13. MyAvatars 0.2 Karthik |

    But isn’t this only applicable if we use pretty permalinks? AFAIK, it doesn’t work on conventional permalinks such as /?p=xxx. Please correct me if I’m wrong!

  14. MyAvatars 0.2 Nate (Average Joe Blogger) |

    Karthik: This applies no matter what your permalink structure is. If you are using the default structure /?p=xxx and WordPress can’t find the post id that corresponds to xxx, it will return a 404 error.

  15. MyAvatars 0.2 Karthik |

    I tried this out on a friend’s (www.mark-kenny.com) blog and it doesn’t seem to work unless I add it as an else statement in page.php and single.php after WP looks for the actual entry - could you kindly take a look and test any /yyy parameter or even /?p=xxx ?

    If it matters, the 404 page displays nothing but “404 Error”.

  16. MyAvatars 0.2 Nate (Average Joe Blogger) |

    Is your friend currently using a 404.php or an else statement? I went to the following page and got a custom error page.

    http://www.mark-kenny.com/?p=118025

    I’m going to set up a test installation of WordPress to investigate further.

    Does anyone else have any expertise on the question of custom 404 pages and the default permalink structure?

  17. MyAvatars 0.2 Karthik |

    I setup the custom 404 on his single.php and page.php pages. The actual 404.php page only has “404 Error” in h1 tags, of course along with the usual header, sidebar and footer hooks. The same thing works on my blog with pretty permalinks turned on, the 404 you will see on my blog is an actual 404.php.

    I also tried enabling pretty permalinks on his blog to test if it had anything to do with it, and yes, it worked when I switched!

  18. MyAvatars 0.2 AskApache |

    Don’t forget to add Ajax Google Search Results to your 404.php with my plugin AskApache Google 404 (released today)…

    By the way Nate, Check this if you can’t see 404.php

    function aa_errorfeed_redirect() {
    global $wp, $wp_query;
    include(TEMPLATEPATH.’/404.php’);
    }

    function aa_errorcheck_url(){
    global $wp, $wp_query;
    include(TEMPLATEPATH.’/404.php’);
    }

    add_action(’template_redirect’, ‘aa_errorfeed_redirect’);
    add_action(’init’,'aa_errorcheck_url’);

  19. MyAvatars 0.2 Nate (Average Joe Blogger) |

    AskApache: Thank you for that information.

    Karthik: I’ve installed a test version of WordPress and it seems you are correct. Here are some ways to get around this:

    1. Use an else statement like your are doing currently. (Probably not the best since you basically have multiple copies of your 404 page)
    2. Use AskApache’s code above.
    3. Add the following to your .htaccess file.

    ErrorDocument 404 /index.php?error=404

    Using one of these methods should ensure that your visitors see your custom 404 page.

  20. MyAvatars 0.2 Karthik |

    Thanks for looking into that Nate, it did take me a while to figure it out! Since the else statement is doing good, I think it may be best left that way (even if you use pretty permalinks, you generate the same page under different URLs: http://www.avgjoeblogger.com/blogging-basics/are-you-losing-readers-from-your-404-pag/ and http://www.avgjoeblogger.com/blogging-basics/are-you-losing-readers-from-your-404-pa/ take you to the SAME content, although the URLs are different. (Don’t be horrified, I’ve removed a couple of letters from the end of the link) So the duplicate content penalty will be the same either way!

    Which is why I like to add post IDs to my URLs - that way, if the post ID makes it into the URL like http://www.iamkarthik.com/AnyStringHere-11/ instead of the actual post URL which is http://www.iamkarthik.com/7-steps-to-creating-a-successful-community-11/ you are still taken to the actual post. (A redirect plugin would do well here which 301 redirects wrong post URLs permanently to the right ones to avoid the duplicate content penalty, I’ve just not got around to doing that yet)

    On a similar note, having post IDs on your URL also help if in the future, you change your permalink structure.(in your case, if you decide the URLs get too long and decide to remove the category name from the URL)

    Sorry about such a long comment, I guess a post may have been better!

  21. MyAvatars 0.2 BlogBroker » Create a Custom 404 Error Page for Your Blog |

    […] you are a WordPress user (as the majority of ProBlogger readers are) I would suggest you look at a post on 404 pages that Average Joe Blogger posted on the topic a few days back which reminded me to fix my own 404 […]

  22. MyAvatars 0.2 [digest] Elements of a good Custom 404 Error page on your blog |

    […] Check out also Average Joe Blogger’s post on 404 pages. […]

  23. MyAvatars 0.2 Create a Custom 404 Error Page for Your Blog | MegaBlogg Free Blog Host |

    […] you are a WordPress user (as the majority of ProBlogger readers are) I would suggest you look at a post on 404 pages that Average Joe Blogger posted on the topic a few days back which reminded me to fix my own 404 […]

  24. MyAvatars 0.2 make money online |

    i just stumbled and dugg this very informative very useful post of yours..

    lady influence

  25. MyAvatars 0.2 404 blues — This and that |

    […] to Skellie, I was directed to an article about customising your 404 page, and to this very cool collection of custom […]

  26. MyAvatars 0.2 Terinea Weblog |

    Check out Redirection plugin for wordpress. It logs 404 pages and then allows you redirect any futures request to revelant pages.

    Jamie