A search widget can be added to your site to empower your users to search your website content for keywords. A demo can be found on the homepage of this site.
The search widget may either be powered by the built-in algorithm (based on Fuse.js) or powered by Algolia. Alternatively, you can create your own third party (e.g. Google) search widget by following the guide in the Alternatives section below.
To enable the search widget:
- Academic v2.4+ is required. Update if necessary.
config.tomlchoose your search provider
home/search.mddoes not exist, copy the file from
activeto true in order to activate the search widget
Continue reading below to learn how to configure your desired search provider.
To use the free integrated search engine:
engine = 1
Note that this search engine runs entirely in the web browser on the visitor’s device. Thus, it is not scalable to a very large number of pages. If you have a very large amount of content, we recommend opting for a server side search engine such as Algolia or Google (see below).
engine = 2
- Register a free Algolia account and follow their wizard to create a new search app
- Build your site by running the
hugocommand in Terminal or Command Prompt
- Upload the generated
public/search.jsonfile to the Indicies page in your Algolia dashboard
- Paste the Algolia App ID, API Key, and Index Name from the Indicies and API Keys pages of your Algolia Dashboard into the
engine = 1to activate the Algolia search engine
- Serve (or build and upload) your site and test out the shiny new search widget on your home page 😄
Note that whenever your content changes (e.g. you add a new page), you will need to re-build and re-upload the search index to Algolia.
engine = 0
active = falsein its front matter
Alternative search providers, such as Google search, are not integrated into the search widget, but can be implemented by creating your own custom widget. For example,