Published by Mijingo

tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Enhance your 404 page with ‘were you looking for’ suggestions and search!

User's avatar
  • Posted by JonnyUK
  • June 10, 2009
  • 3 people have found this tip helpful.

It can be pretty easy to kill a previously working URL simply by editing the url_title (or title) of an entry, which can go unnoticed for you on your website (because your links are likely to be dynamic and coded with the {url_title} variable so they will get updated at the same time), but may cause problems for others who have either bookmarked the old URL or have linked to it from their own website.

Providing you’ve setup 404 error pages and strict URLs properly your users will at least see an error message, but this can be misleading as it may suggest the entry was deleted when in fact is was simply amended and renamed.

A great way to enhance your 404 page would be to add a “Were you looking for / Did you mean?” suggestion feature which would provide your visitor with an alternative link which would (ideally) point to the content they were trying to get to. To add to this, you could also add search functionality so that users could manually submit a search for the content if the system could not suggest a page, straight from the 404 error page.

But this sort of functionality is not built into Expression Engine, and it would be pretty complex and time consuming to set it up yourself.

Luckily, Google Webmaster Tools provides exactly what I’ve described above with their ‘Enhance 404 widget’.

All you need to do is setup a Google Webmaster Tools account for your website and then drop in a small amount of generated javascript code in your 404 error page template in Expression Engine.

Now, when your visitor heads over to an old link such as http://www.example.com/news/article/website_is_launched, your 404 error page will be served and should suggest the correct link, http://www.example.com/news/article/website_is_launched_amended, otherwise it will provide a google search box pre-filled with the text “website is launched” which can then be used to search your website indexes for the correct link to the amended article.

A simple, lightweight and effective method of helping your visitors find the content they were trying to get to!

Note: Please take a look at my other tip at http://eeinsider.com/tips/view/handle-incorrect-urls-properly-avoid-search-engine-penalties-and-help-users/ for information on how to setup 404 error pages to display when links to incorrect entries are used.

JonnyUK13:29 on 06.10.2009

Even eeinsider.com could benefit from this tip! You will notice if you visit a URL like ‘http://eeinsider.com/random_link’, instead of redirecting to a 404 page, Expression Engine is serving up the index template of the default template group, which contains the exact same content as http://eeinsider.com/. Search engines will see this is as duplicate content which could harm rankings for that page!

JonnyUK13:31 on 06.10.2009

Oops, the above comment was meant for my other tip - feel free to delete it from this one! My bad.. it’s late =p.

Add Your Comment?

You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.

Sign up now (or login).

Search EE Insider Tips
Sponsored By