Get the most out of the site search function on your website
Ways to help users find what they're looking for on your website using the search function.
Companies like Google have gotten us used to searching for what we want and getting immediate, relevant results. However, the internal search function on your website won’t always meet these expectations. Let’s look at some ways to improve the experience.
How the internal site search function works
The internal search function allows the website visitor to find content on your site by typing a search term into a search form.
In their most basic form, search functions work like this:
Content is added to the search index.
A search algorithm scores the indexed content.
The user enters a search term/query.
Search results display the content based on its score for the search term.
Make sure the content is indexable
Not all content is added to the search index. For example, bots can’t read an image, so you need to add alt text to images on your site. Say that you display a company name using a picture of its logo. The content won’t appear in the search results for the company name unless the company name is set as the image’s alt text and the alt text is set as indexable.

In the Craft CMS, an entry’s title field is indexed, as well as any text in the entry’s content fields that have the “Use this field’s values as search keywords” checkbox selected. Check that the fields with content you want to be found have this checkbox selected in the field settings.
Optimise your content
The search algorithm gives the content a score for the search term and displays the entry with the highest score first. To optimise the content for the search algorithm, you need to know a bit about how it works. You can apply this knowledge as you write and organise the page content.
We can’t cover every search algorithm available, so we’ll focus on the native search algorithms that come packaged in two of the most popular content management systems: WordPress and Craft.
The search algorithm in the Craft CMS works roughly like this:
It gives the entry a score if it includes the keyword(s) used in the search term in one of the entry’s indexable content fields.
It gives a higher score if it includes the keyword(s) in the entry’s title field.
If the search term has more than one keyword, the algorithm gives the entry a higher score if it includes all the keywords. The score is higher still if the keywords are in the same order.
Get more details about how Craft’s search algorithm works from their documentation.
WordPress’ search function works roughly the same (it used to order the search results by the date the entry was published but now uses better scoring).
Include synonyms in your content
Search engines like Google Search use natural language processing to understand how different words and phrases relate to each other. For example, they know that “childcare” and “nursery” relate to each other. As your CMS’s native search algorithm doesn’t do this, you need to make sure that you include synonyms and related words in your content.
Add misspellings and typos to a custom field
At William Joseph, we have seen during user testing that people with dyslexia prefer to use the site search (they find it less overwhelming than a wall of site sections). This means that the likelihood of misspellings in their search is higher.
When you use Google Search, it corrects misspellings and typos. But this won’t happen when using your site search (your site doesn't have the data that Google has collected over the past 20 years). So, for example, if you enter “suporters” (with one “p”) in your site’s search form, you won’t get the entry titled “Our supporters” in the search results.

However, we don’t want misspellings and typos in your content. One solution is to get your developer to add a field to your content editor but not include it in your entry template. You can then add these words to the entry using this field without displaying them to your site visitors.

Filter the search results
Your developer can edit your search form function to search a particular section of your site. For example, if you have a page that lists your staff, add a search field to let the user search for someone by name or role. Or, if you have an events section, include a search field at the top of the events page that only lists event entries in the search results.

Add popular search terms as autocomplete options
Modern browsers store search terms previously entered across domains. These then come up as autocomplete options when you use a search field on a different domain name. This means you don’t have to type out the full word or phrase – you can select it from the list displayed when you start typing into the search field.
If you have a list of popular search terms used on your site, get your developer to set these as autocomplete options on your site search form (I love the free Awesomplete widget).
Alternatively, they could query the titles of the entries on your site and use these as autocomplete options. An example of this being used well is the university search function on the Student Space website. They use the university’s name as the entry title, so the names are displayed when you start typing in the search field.
Internal search checklist
So to summarise, here are the tips to get the most out of the internal site search function:
Make sure the content is indexable.
Optimise your content.
Add misspellings and typos to a custom field.
Include synonyms in your content.
Remember: if the word isn’t included in your content, then the content won’t appear in the search result for that word.
Filter the search results.
Add popular search terms as autocomplete options.
More options
The suggestions here should improve the usability of your site’s search function. For a fee, there are also other platforms to use for your site search function, like Algolia. Or to take advantage of Google Search’s algorithm, use their API.