Search: Algolia
Table of Contents
Configure Algolia Search Client
Select Algolia as the search client in your config.toml file:
[params.search]
client = "algolia"Also, add configuration options for Algolia:
[params.search.algolia]
appId = ""
indexName = ""
searchApiKey = ""params.search.algolia[Map]:appId[String]: Algolia Application IDindexName[String]: Name for Algolia Indices
default:engimo_sitesearchApiKey[String]: Algolia Search-Only API Key
You’ll find various information related to your Algolia account in the Algolia Dashboard.
Generate Search Index for Algolia
Algolia will need a search index for searching across your site. So, you’ll need to generate that search index for Algolia before you deploy your site.
Engimo comes with a script for generating the search index for Algolia: /scripts/generate-search-index-algolia.js.
Install Dependencies
Node.js must be installed on your system for using the generator script.
It also needs the following npm packages:
algoliasearchglob
For installing algoliasearch and glob globally use the following command:
npm install -g algoliasearch globSet Environment Variables
The generator script uses the following environment variables:
ALGOLIA_APP_ID(required): Algolia Application IDALGOLIA_ADMIN_API_KEY(required): Algolia Admin API KeyALGOLIA_INDEX_NAME(optional): Name for Algolia Indices
default:engimo_site
Run the Script
After you’ve generated your site with Hugo, run generate-search-index-algolia.js with node.
If Engimo is installed under /themes/engimo directory, you’ll run it as:
node ./themes/engimo/scripts/generate-search-index-algolia.jsThe generate-search-index-algolia.js script accepts an optional argument for Hugo’s publishDir (relative to your site’s root directory).
So, if you’ve got a different publishDir (say site), pass it as the first argument:
node ./themes/engimo/scripts/generate-search-index-algolia.js siteIf the generation was successful, you’ll see output like this:
Algolia Index Generated for: /search/index.json
That’s all. Now you can deploy your site.