You appear to be using an unsupported browser, and it may not be able to display this site properly. You may wish to upgrade your browser.
Information
We use cookies to collect anonymous data to help us improve your site browsing
experience.
Click 'Accept all cookies' to agree to all cookies that collect anonymous data.
To only allow the cookies that make the site work, click 'Use essential cookies only.' Visit 'Set cookie preferences' to control specific cookies.
A list of all the search results found after a user has run a site search.
About this pattern
After a user has carried out a site search, you can show a list of search results.
All search results lists must have the following elements:
results count
pagination for results over multiple pages
a ‘no results’ message
The following elements are optional:
search term spelling suggestions
related search terms
‘sort by’ to help users sort results
The search results list can be unfiltered or you can give the users search filters.
A search results list is made up of individual search results. Read the guidance on creating an individual search result.
Preparing your content
Before implementing search, you must audit your content to ensure search results are user-focused. This includes:
cleaning up your content — for example, by removing incorrect or outdated content and ensuring there are no duplicate titles
identifying missing data that would affect search results — for example, by reviewing search terms through an existing search tool or external search
cataloguing the data points you have for each piece of content, such as date of publication or topic area — these will dictate the filters, page metadata and sorting options you can provide
Search term spelling suggestions
If a user searches for a term flagged as a misspelling, add the corrected spelling to the search. This may produce more results.
Give the user the option to perform the search again with only the suggested corrected spelling or only their original search term.
Performance data shows that on mygov.scot, users click on the first alternate spelling suggestion around 50% of the time.
Our research shows that there is little value in adding more than 3 suggestions.
Results count
Show the results count at the top of the list of results. This tells the user:
where they are within the results count
the total number of results
the search terms — both correct and misspelled
Performance data shows users prefer fewer search results. It’s quicker and easier for them to find relevant results. A good internal search tool limits the number of results.
Pagination for results over multiple pages
Split search results over multiple pages if there are more than 10 results. Each page should contain 10 results.
Users choose a page by selecting a page number at the bottom of a search results page, starting at page one. Highlight the page number the user is on.
You can monitor the click-through rate on a search result using the in-built tracking. The click-through rate of search results on mygov.scot shows that:
over half of users click on the first search result
96% of users click on first-page results — they rarely navigate to deeper pages
When using the pagination component within a search results list, some additional changes should be made.
On the first page of results
Show the number of results and the search term — for example, 87 results for [search term].
The attribute data-total, applied to the ds_search-results__list list element, contains the total number of results. It calculates the relative position of each result within the tracking attribute script.
On subsequent result pages
Show the position within the set of results alongside the total number and search term — for example, Showing 21 to 30 of 87 results for [search term].
The additional attribute start, applied to the ds_search-results__list list element, contains the starting position for the current displayed results within the set of results and is by the tracking attribute script.
Sorting search results
Use the ‘sort by’ dropdown to allow users to sort the search results into the order that’s most useful to them.
Put the ‘sort by’ dropdown above the search results.
Examples of sorting options are:
date of publication
most relevant
newest
User research can show the sorting options that are most useful to users.
Only let users sort by an option if that sorting option is across all content. For example, date of publication. Missing data leads to incomplete search results, causing users to miss relevant content.
If the sort is automatically submitted by JavaScript, then add the js-initialised class to the ds_search-results element. This removes the ‘apply sort’ button.
Performance data
Performance data shows that fewer than 5% of search users on gov.scot use the 'sort by' dropdown. Therefore, you should do user testing to find out whether you need to offer users a way to sort results.
By default, you should sort search results in a logical way which may mean you do not need to have a 'sort by' option. Usually, this means sorting by most relevant results first. However, depending on the type of content, your results may be best sorted by publication date.
Related search terms
You can list related searches that may be useful to the user.
Put a list of links at the end of the search results page underneath the pagination. Clicking on a link should start a new search for that search term.
You should limit the number of related search terms to 6 or fewer.
No results message
You should display a no results message if a user has searched for something and there are no results.
The message should:
clearly explain there are no results to display
give the user some hints for how to improve their search — for example, by checking the spelling is accurate or searching for something less specific
Website analytics
Many analytics tools offer tracking for site search. The following setup covers more complex tracking to understand:
which search result users interacted with from a search results page
how other interactive elements are being used
Tracking interactions with search results
You should track user interactions with search results to understand if internal search engines are providing useful results.
Tracking works through the query being available from the page URL, the click text, click URL and a data attribute showing the result’s position.
Tracking how other interactive elements are used
If a spelling suggestion is provided, you can track clicks to the suggested search terms through the page URL (which contains the original search query), the click text, the click URL and a data attribute.
You can also track:
interaction with pagination using the data attribute with the number of the results page clicked
promoted results using the page URL, the click text, click URL and a data attribute showing the result’s position in the list of promoted results
suggested related search terms through the page URL (which contains the original search query), the click text, the click URL and a data attribute
If you're using the site search on a single-page app or if it's not possible to put the search query into the URL, you could include the query in the dataLayer for the page.
Accessibility
Suggestions for misspellings use WAI-ARIA attributes to give screen reader users more context. They include:
overwriting link text with a more descriptive aria-label for each suggestion
hiding text where it would cause duplication with the links
wrapping suggestions in a nav element with a descriptive aria-label (supporting evidence: mygov.scot accessibility review, March 2019)
You can implement pagination of search result pages in a way that only refreshes part of the page content, rather than the entire page. To tell users of assistive technology when they’ve changed page, you should:
apply an aria-live attribute to the heading that describes the total number of results — so if this heading content dynamically changes, the new position in the list of results is announced
apply focus to the beginning of the content that has been dynamically changed
Evidence
We’ve user tested search filters, search tags and the ‘sort by’ dropdown on gov.scot.
Adding search filters and search tags improved the user experience. Users were able to find the most relevant results.
The ‘sort by’ option also tested well. Users were satisfied they could sort the results in a way that helped them.