In the last post of this series, we talked about what page templates should be available in themes. A few people mentioned 404 templates, but those aren’t page templates at all.
A 404 page is what a user sees when they come across a page that doesn’t exist on your site. Maybe you’ve moved it or deleted it. Maybe the user typed the address wrong.
You can also read the WordPress Codex article on creating an error 404 page.
What will usually happen when a user comes across a 404 page is that they’ll hit their browser’s back button almost immediately, this is especially true of users coming from search engines or a link from another site.
What we want to happen is for the user to stick around even if they didn’t find what they were looking for.
What should be included in the 404 template?
Most themes should have a 404 template. It’ll be named 404.php and located within your theme files.
The bad thing about these templates is that they probably don’t do much for your site. Even the WordPress Default theme only shows this:
Error 404 – Not Found
That’s not very helpful, now is it? I imagine most themes don’t alter this much.
You’ll probably want to modify whatever 404 comes packaged with a theme to suit your site’s needs, but maybe you already have some things in mind that should be included already.
What I’d like to hear from you is what you think should be included by default. Are there plugins that should be supported? Should it be widgetized? Should it list all posts? Archives? Categories?
You decide.
I like this plugin: http://www.askapache.com/seo/404-google-wordpress-plugin.html but I don’t think it should take a plugin to make the 404 page more interessting.
In my opinion, 404.php should have something useful to the visitor such as links to archive posts and pages or at least putting a link to the sitemap page or the archives page would be nice.
Providing a search system in the 404′s content area is good idea, too, so the visitor will not hit the “Back” button but will search what s/he wanted, instead.
There is a possibility to implement a code that extracts the typed url’s phrase and changes it to search or “Did you mean …?” or something like that. But, this can only be done when the permalink structure is selected as Pretty Permalinks and has the page/post name as the location path (e.g. http://justintadlock.com/archives/2008/10/04/if-you-were-a-wordpress-theme-developer-404-templates).
However, in my opinion, 404 should stay neatly clean. It should have its own sidebar or no sidebar at all.
That’s all I think about 404.
Yeah I think that 404 pages should try to keep the visitor on the website, with a search function, maybe top posts or cateogories. And also what J Mehmett was mentioning about the url guessing script, Google has a sort of plugin with their website managment tools that you put onto a 404 page. When someone mistypes a url say, it will try to suggest the proper url based on its search index for your site.
Well, IMO, the first thing you have to do is avoiding 404 errors. There is a nice Redirection plugin which can help you doing so. (p.ex. It automatically adds a 301 redirection when a post’s URL changes)
But when a vistitors lands on a 404 page from a search engine, it seems interesting to me to use the (Google / Yahoo) search query they used on an internal wordpress search and return the 3 most relevant results below the words “Maybe you were looking for this?”. Joost de Valk wrote an interesting article about improving your wordpress search results btw.
Also a very short but clear message why they are getting this 404 page is essential to keep people on your site. If things really look like a big error page it’s more than obvious that visitors start running away again.
It would, in my opinion, be a great addition to a theme if there was some easy way built-in to edit the 404 page. The default page in WordPress, and most themes, is pretty well useless.
I’ve changed mine so that it has a somewhat more helpful message, links to various archives, my contact page, and my standard blog sidebar. One other thing I would like to include, but haven’t been able to get working, is a searchbox in the main text — there is one in the sidebar though. I’ve also included a jokey picture, which is really corny, but I like it.
Most of what I’ve put in wouldn’t be out of place on the majority of sites, and so could be built into a theme as standard. But, if nothing else, an easy way to add what you want without having to directly edit php files (which is why I wondered about it for page templates) would be a real help.
If we are too lazy to include the 404.php, just use the
[?php else : ?]
after the post loop… Very convenient…
But, I do include 404.php in my theme…
We can make our 404.php become more interactive by,
1. Adding search form.
2. Adding your archive list or categories.
3. Or even put your sale ads in it…
Just an opinion…
Many websites use redirection when 404 error returns. So the mistyped URL will get back to the main index (home page) and I think this is the worst 404 ever. The user will confuse retrying the same URL, so its nice to tell the visitor that what s/he is looking for was either removed or never existed.
@Jylan Wynne,
Yea. The guessing script is pretty nice and will make all the possible efforts to keep the visitor on site.
Thanks for the feedback so far, everyone. I’m just popping in to see how things are going. I’m going to look over everything once I get settled in.
I like the idea of having a script that tries to guess what the user was searching for.
I have found it useful to include a sitemap on a 404. For me, if I cannot find what I am looking for because it has been moved, I like having the option of looking at all of the pages and posts in the site right there on the 404 error page.
An example would be: http://www.aleeya.net/whatever
(which doesnt exist) it tells you that the page is not found and gives you an option to look at the sitemap to see what is there.
Though I like the idea of the 404 error page guessing, I can not seem to locate what I thought was a plugin for that which I saw.
Also, for search engines, it is nice to have the internal links to other pages for a search engine to see if the page has been moved, etc. I have read a lot of positive things about that and SEO
erica stjohn
I’m thinking some sort of site map might work, but at the same time, I wouldn’t want to overwhelm the visitor with too much. Maybe a site map of the pages only would work best with the added benefit of the guessing plugin.
If you come across that plugin, be sure to link to it.
here you go. I believe this is the one I was looking for that guesses
http://wordpress.org/extend/plugins/smart-404/
erica stjohn
I know it’s a late reply, but I’ve actually incorporated Smart 404 into my latest theme, Hybrid.
as I said, I work with WP themes, and they have a 404 page, its very important, thanks for the post!