The Ghost team released one of the most requested features since the platform was launched: a built-in native search function. The search works with all Ghost themes, giving your readers easy access to search all published posts, tags, and authors on your site.
The official Ghost themes were updated and now include this new feature, but even if you are using a custom theme, you can easily add the feature to your site.
Adding the search function
As mentioned, if you are using your own theme, a customized official theme or a premium theme without the search function, you can still add the new native search.
There are two ways:
- Add the search with a link (
#/search
) - Add the search with the data attribute (
data-ghost-search
)
The easiest way to start is using the link, for this you don't have to change
the themes files. You can simply add a link in navigation pointing to the #/search
.
The label can be 'Search' or even an emoji (🔎).
The other way is using the data attribute, this means you have to edit the theme
files, but the advantage is you can place the search trigger element wherever
you want. You can add the attribute data-ghost-search
to any element, but
ideally it should be a button, for example:
<button class="search" data-ghost-search>{{> icons/search}}</button>
You can place this element in the header or in any other place you want, and when clicked it will open the search popup.
You can open the search UI directly by using the Ctrl/Cmd + K
keyboard shortcut
Technical details & limitations
Taxonomies for tags and authors must be present for search results to include tags and authors.
There are a few limitations for the native search function:
- the search feature does not index post content, the search is performed based on post titles, excerpts, authors and tags -to avoid performance issues, the search function can only index 10,000 posts (most recent posts)
For larger sites (more than 10,000 posts) it's recommended to use an advanced search functionality like Algolia.
Conclusions
The new native search is a great addition to the Ghost platform and although it's limited, there are plans to improve it in the next iterations. Overall it's an easy way to provide users the possibility to find what they're looking for with a single click.
If you are looking for alternatives check the post about Ghost search options.