---
cover: images/00057.webp
---
Registering for Algolia
- Go to the Algolia website and create an account.
- Navigate to the Dashboard -
Search-Indexpage, click+ Create Indexto create an index, and remember the index name. - Go to the Dashboard -
Settings-API Keyspage and note the following:Application IDSearch API KeyAdmin API Key
Configuring Algolia in Hugo
- Add the following configuration to the root
hugo.tomlfile. This ensures that when runninghugoto generate the site, analgolia.jsonfile is also created in thepublicfolder for Algolia search.
[outputs]
home = ["Algolia", "HTML", "RSS"]
[outputFormats.Algolia]
baseName = "algolia"
isPlainText = true
mediaType = "application/json"
notAlternative = true
- In
params.yml, setalgolia_search.enabletotrueand fill in the relevant details (Note: Only use the Search-Only Key here. Never enter the Admin Key, as it could lead to security risks!).
algolia_search:
enable: true
appID: # The Application ID mentioned above
apiKey: # The Search API Key mentioned above
indexName: # The name of the created index
Uploading the Index
Direct Upload
Run
hugoto generate the site. This will create analgolia.jsonfile in thepublicfolder.Go to the Dashboard -
Search-Indexpage, find the newly created index, clickAdd records-Uploading file, and select thealgolia.jsonfile to upload.
Using the atomic-algolia Package
Use the atomic-algolia package to upload the index. The following steps are from the package’s documentation.
- Install the
atomic-algoliaandcross-envpackages:
npm install atomic-algolia cross-env
- After running
hugoto generate the site, execute the following command:
npx cross-env ALGOLIA_APP_ID={{ Application ID mentioned above }} ALGOLIA_ADMIN_KEY={{ Admin API Key mentioned above }} ALGOLIA_INDEX_NAME={{ Name of the created index }} ALGOLIA_INDEX_FILE=algolia.json atomic-algolia


Leave a comment