Look, it happens. A visitor is going to land on your site trying to get to a page or post that doesn’t exist. The question is this: “Are you going to drive your visitor away to another site, or are you going to try and help them find what they’re looking for?”
Hopefully, you chose the latter – you want to help your visitor find what they want. If you don’t care, then this post isn’t for you 🙂
So what can we do to help? The first thing to do is to let your reader know in a nice way that something’s not right. You can use the familiar ‘404 – Not Found’ term, with a little bit of an explanation:
404 – Not Found
Oops! The page you’re looking for isn’t here. Maybe we removed it, maybe it was never here. No matter – we can help you find what you wanted. You can…
Then we can show a list of some helpful actions to take:
- Check the list below to see if what you’re looking for might be there
- If you typed the page url address (www.ilikewordpress.com/showme), in the address bar, make sure that it is spelled correctly and the case (CAPITAL and small letters) is correct.
- Go to the I Like WordPress home page and look for links to the information you want.
- Use the navigation categories to the right to find the link you are looking for.
- Go back to the page you just came from.
- Use the search box at the top right of the sidebar to search I Like WordPress.
So, from the top:
- In our 404 page coding, we can use some scripting that searches your blog posts for what could be a keyword in the URL (the showme part)
- We can echo the url that the visitor typed in or clicked a link to that landed them here. If we get fancy, we can actually tell whether the visitor clicked a link or typed in the address themselves. Hint – if they clicked a link, we might want to get the link corrected. Be a little careful about echoing the URL, though — if it’s a long one, it could break your layout as most browsers won’t split a link in the middle.
- We can give a link to our home page. Maybe the info they want is easily findable from there.
- We point out the navigation links that are available: categories, archives, latest posts, etc.
- Suggest that the visitor use our handy-dandy search tool to find their information.
Really fancy stuff
I mentioned in the first option that we can use some scripting to search for what might be a keyword in the URL that wasn’t found. What we’ll do in a later post is learn to extract the last part of the URL and use it as a search term. We’ll use a database query that has been bullet-proofed against malicious use.
In the meantime, check out a really bad example of a 404 – Not Found page: what your 404 page should NOT look like.
Update: coincidence or not, Macy’s (above link) just changed their 404 page 🙂 I’ll leave the link for posterity, but I’m sure you’ve seen examples of useless 404 pages.