Adding Search to Your Own Website
Site features · 8 min read ·
A search box on your own site helps visitors find things and shows what they want. How to choose a setup, design it, keep it accurate and learn from it.
Most of this site's guides are about getting people to your website. This one is about what happens once they arrive. A visitor who knows what they want, a product, an opening time, a policy, an article you wrote last year, may not want to browse. They want to type a few words and find it.
A search box on your own site can serve that visitor well. It can also be a source of insight, because it shows what people look for. But a poor search box is worse than none. This guide explains when you need one, how to choose a setup, how to design and maintain it and how to learn from it.
Do you need one?
Not every site does. Ask yourself:
- How many pages do you have? A site of a dozen pages with clear navigation usually does not need search. A site with hundreds of products, articles or listings usually does.
- Do visitors come with specific needs? Shops, directories, libraries of guides and documentation sites benefit most.
- Is your navigation struggling? If people email to ask where things are, a search box may help.
- Can you maintain it? A search that returns poor results can frustrate people more than having none.
If the answer is mostly no, put your effort into clearer menus, internal links and a good contact route.
How internal search works
Internal search is a small version of what web search engines do. The software collects your pages, breaks the text into words and builds an index. Wikipedia describes search engine indexing as the collecting, parsing and storing of data to enable fast and accurate retrieval, and explains that a common structure, an inverted index, records which documents contain each word so that a query can find matches in milliseconds. When a visitor types a query, the system looks up the words in the index, ranks the matching pages and shows a list.
Good internal search also handles practical problems: plural and singular forms, typos, synonyms, partial words and ordering results by relevance. Basic tools do some of this, and better tools do more.
Choose a setup
Options range from simple to sophisticated.
Built-in search
Many website platforms include a search function. It is the easiest to start with, and often adequate for small sites. Check its quality: does it find pages by their content or only by title? Does it handle typos? Does it let you adjust results?
Plug-ins and add-ons
For popular platforms, add-ons can improve search with better ranking, filters and suggestions. Choose one with good reviews and active support, and watch the effect on page speed.
Hosted search services
Specialist services crawl your site and offer a search box and results you can embed. They often provide better relevance, analytics and features such as suggestions, though they add a dependency and sometimes a cost. Check the terms, what data is sent to the provider and the privacy implications for your visitors.
Custom-built search
For large or unusual sites, a developer can build search on top of an indexing system. This gives the most control and requires the most work.
For most small businesses, start with the built-in option or a reputable add-on and see whether you need more.
Design the search box
A search box is a small piece of design with large consequences.
- Put it where people expect it, usually at the top of the page, in the header, on every page.
- Make it visible, with a clear field and a button or icon labelled for assistive technology.
- Label it properly for screen readers and keyboard users.
- Make it large enough to tap on a phone.
- Offer a hint, such as "Search guides and products".
- Keep it simple. One field is better than several.
For results pages:
- Show the query at the top, so people can see what was searched and edit it.
- List results clearly, with a title, a short snippet showing where the words appear and the address or category.
- Highlight matches.
- Offer filters if you have many results, such as by type or category.
- Show how many results were found.
- Handle no results gracefully. Do not display an empty page. Suggest alternatives, show popular pages, offer a contact route and ask whether a spelling is correct.
- Keep the page accessible and fast.
Make the content searchable
A search box can only find what is on the page and in the index. Help it.
- Write clear titles and headings that use the words people search for.
- Use the same words as your visitors, not only your own jargon. If people search for "returns" and your page only says "sending items back", add the word.
- Add synonyms where your tool allows.
- Keep text as real text, not inside images.
- Make sure new pages are indexed quickly, and removed pages disappear from results.
- Avoid duplicate content that confuses relevance.
Keep internal results out of the public index
Internal search results pages can create thousands of low-value addresses. If they are crawled and indexed by public search engines, they clutter results and waste crawlers' attention. Google explains that a noindex instruction tells it not to index a page, and that the page must remain crawlable for the instruction to be seen. Many sites apply noindex to internal search results pages, and some also manage crawler access through their robots file. Choose the approach that suits your platform, and make sure it does not accidentally affect your real pages.
Respect privacy
Search queries can reveal personal information, such as a name, a condition or a problem. Treat them carefully.
- Do not log more than you need.
- Do not store queries with identifying details longer than necessary.
- Say how you use search data in your privacy notice.
- Avoid sending queries to third parties without informing visitors.
- Review any external service for how it handles data.
The Information Commissioner's Office offers advice for small organisations on handling personal information, which applies here.
Learn from what people search for
This is the hidden benefit. A log of internal search queries is a direct record of what your visitors want.
- Top queries: what is most wanted? Make sure it is easy to find, and consider giving it more prominence.
- Queries with no results: what are people looking for that you do not have, or that they cannot find? These are content ideas, or signs that you need synonyms.
- Queries followed by a quick exit: the result did not satisfy.
- Misspellings: add corrections or synonyms.
- Seasonal patterns: what people ask for at different times.
Review the log monthly. Make three changes: add a missing page, fix a poor result, adjust a label. Over a year, your site becomes noticeably easier to use.
Test it like a visitor
Try searches that a visitor might make.
- Your own business name and common products.
- A misspelled word.
- A word in the singular and plural.
- A phrase from a customer's email.
- A product code, if relevant.
- Something you do not have.
Check that results are sensible, in a sensible order, and that the no-results page helps. Ask someone who does not know the site to try. Fix the failures.
Keep it fast and light
A search feature should not slow your pages. Load the search code efficiently, avoid heavy scripts and test on a phone. Google's guidance on helpful content stresses that pages should serve people well. A search that appears instantly and returns useful results fits that aim.
A worked example
A small online shop selling kitchenware has three hundred products and a menu with six categories. Visitors regularly email to ask whether the shop sells particular items. The owner adds a search box to the header using a reputable add-on, and tests it with twenty queries. She finds that "casserole" returns nothing because products are called "stew pots", and that misspellings return no results.
She adds synonyms, improves the no-results page to suggest categories and a contact link and sets noindex on the results pages. After a month, she looks at the query log. The top query is "dish towels", for which she has a category but not a visible link, so she adds one. Several queries are for "gift", so she creates a gift guide page. Emails asking whether she stocks something fall, and the guide brings a steady trickle of visitors.
Common mistakes
- A search box that returns poor results.
- No help when nothing is found.
- Results pages indexed by search engines.
- Hidden or tiny search fields.
- Never reading the query log.
- Ignoring privacy.
- Slow scripts.
A checklist
- Need established
- Setup chosen: built-in, add-on, hosted or custom
- Visible, labelled, accessible box
- Clear results and a helpful no-results page
- Content uses visitors' words
- Internal results kept out of public indexes
- Privacy considered
- Queries reviewed monthly
- Tested as a visitor
- Fast and light
The search page here is a minimal example of the idea, the categories page shows browsing by topic and the submit page lets a business add a listing that people can find through search.
Frequently asked questions
Can I just embed a public search engine? Some sites do, but results may include pages you do not control. A dedicated internal search is usually better.
Should I show popular searches? It can help visitors, as long as they are accurate and not manipulated.
How often should I review the log? Monthly is a good rhythm.
Questions and answers
- Does a small site need its own search?
- Not always. A small site with clear navigation may not. A site with many pages, products or articles usually benefits.
- What are the options?
- Built-in search from your platform, a plug-in, a hosted search service, or a custom-built index.
- Should internal search results be indexed by Google?
- Generally no. Internal search result pages are usually thin and numerous, so many sites keep them out of the index.
- What can I learn from it?
- The words visitors search for, which show what they want, what they cannot find and what words they use.