close button

How to add a search box to your website

Published by

In this day and age, it’s almost impossible to run a business without some sort of web presence. Let’s face it, phonebooks are dead and word of mouth can only take you so far. Whether it’s a Facebook page or a Google+ site, people need to find your company online. Pre-built social media sites are a good start, but to really get serious about your online footprint, you’ll need your own, personalized website. And the features that are built into that site are just as important as the information the pages contain. One of the questions that often arises when designing a site is whether or not a website search box is a necessary feature on your site. We’ll take a look at that here.

search box

Do you need a search box on your website?

There are many types of sites out there on the web and they range from the very simple layouts of a just a few pages and pictures to the very complex that contain thousands of lines of code and information. Chances are your business is going to fall in there somewhere closer to the smaller site. So does that mean you need a search box? The answer is… maybe.

Some basic research will point to some statistics about search features. For example, most people who use a website’s search bar generally click on it immediately after accessing the page. This suggests that users do use the feature to navigate the site. Now if you are looking at a website of only a few pages, it may not be necessary, but anything over that, it is probably going to come in handy for your visitors. And if there one important aspect of web design that can’t be ignored, it’s how user-friendly it is.

A website search box can capture query data. Next to usability, the most important aspect of a web presence is data collection. We want to know as much about our visitors as we can. This helps us shape our business plan to meet their needs thus building a stronger and more competitive company. So the utilization of a search featured coupled with some analytics software (there are many providers and they are often easy to implement), you’re building your business from the back end.

If you get visitors to your site, the last thing you want them to do is leave. A search bar can help with this problem as they won’t have to leave your page in order to do a search. In addition to that, no matter how simple your web hierarchy is, there will be people that surf in that won’t understand it. Rather than have them leave in frustration, it’s always best to provide as many ways to find information as possible. It also cuts down on the number of clicks visitors have to register before finding the data they want.

At the end of the day, the search feature streamlines navigation, increases user interaction, lengthens visit time and provides valuable data about your user’s data preferences. In any case, adding a search to your site will always be beneficial.

Add a search script to your website

Now that the decision has been made to add the search feature, it’s helpful to know exactly what methods are out there to build it. The most commonly used search boxes are scripted in a coding language such as PHP or Perl. The code is housed on the server and when information is typed in the box and sent, the server-side engine runs the script and produces the results.

Some search scripts will run a crawl your entire website each time a search is made by a user. Other scripts will periodically crawl your site and create an search index, and it is this index that is searched whenever a user inputs a search query. Advantages of the first approach are:

  • It’s easier to set up
  • It’s always up to date with the latest changes on your website

The main drawback is that it can be slow to search on big websites, so it is only really an option for small websites.

On the other hand, index-based searches are much faster to run than non-index based search engines. But drawbacks are that:

  • It’s harder to maintain: it has to periodically crawl and update the index
  • Depending on how frequently the site is recrawled and index updated, it might be a little while before new content appears in the search

Some popular PHP and Perl script search engines for your website include:

Some of the advantages of a scripted search include privacy. Most likely it is going to be a server-side script, so your code isn’t visible to anyone who doesn’t have access to your web directories. Customization is also a big plus. Code can be written to fit the owner’s goals and is highly customizable. Scripts also afford the owner complete control over adding, updating and features. The downside is that the owner will either need knowledge of the scripting language or have the resources to hire a programmer who does. Those who opt for the latter can wind up paying big bucks for complicated projects.

Add a third-party search box to your website

Another option for website owners is to utilize a search feature from a third party. Many internet companies out there will have products where the code can simply be copied and pasted in the appropriate areas and the search box becomes functional. The obvious advantages here are that you do not need any programming or scripting knowledge whatsoever to use these tools. They can also be free to use from some providers – your website hosting company may already offer them. Some disadvantages with this option are the loss of some control over how your bar works. You may be offered slight customization, but nothing close to what you get if you script the search yourself. Another pitfall to look out for is banner advertising. Some providers will advertise on your site for whatever they want in exchange for the use of their search products. You may also see some of your bandwidth being used by the third-party code as re-indexing your pages (checking for new content to include) is often performed in order to provide more accurate results. Some free search bar providers include

Major Site Providers

Finally, you can use a service such as Google’s Custom Search to build a basic search feature. Much like the smaller third party providers, you’ll run into some of the same advantages and disadvantages. Google offers a free feature that offers limited customization and includes advertisements and also a customizable version that gives you a little more control (such as removing ads and Google branding), but you’ll pay a little money for it each year. The advantages, again, are on par with smaller providers in that you needn’t require any scripting knowledge to add the feature to your pages.

Google search

In short, a search function is a helpful tool for both your visitors and your business and there are many options out there to suit a wide array of needs.

Main image: t_buchtele
Content images: Peter Morville, Global Panorama