# Searching Hugo sites with Algolia

**URL:** <https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820>\
**Category:** tips & tricks\
**Created:** [March 2, 2018, 6:09pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820 "2018-03-02T18:09:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Forestry.io](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/forestry.io/32/5387_2.png) [@Forestry.io](https://discourse.gohugo.io/u/Forestry.io)\
**Post date:** [March 2, 2018, 6:09pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/1 "2018-03-02T18:09:11Z")

</div>

We just published a new article in our on-going series called _[Frontend Friday](https://forestry.io/categories/frontend-friday/)_. Check out how to implement a performant search using Algolia for your site ⚡ by Hugo 👇. The article is written by @chrisdmacrae

> **[Static site search with Hugo + Algolia](https://forestry.io/blog/search-with-algolia-in-hugo/)**
>
> For this week on Frontend Friday, we’ll be covering how to set up lightning ⚡️ fast search for your Hugo site using Algolia, the SaaS (Search as a Service 😉 ) provider. We published a Jekyll-focused version of this guide last week.
> Algolia’s...

Chris even added some extras to make your algolia searches extra efficient, fast and low-maintenance. Additional credit goes to @budparr for testing Chris’ NPM plugin [atomic-algolia](https://www.npmjs.com/package/atomic-algolia).

---

<div class="post-metadata">

**Author:** ![Yudy\_Ananda](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yudy_ananda/32/5664_2.png) [@Yudy\_Ananda](https://discourse.gohugo.io/u/Yudy_Ananda)\
**Post date:** [March 4, 2018, 6:44am UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/2 "2018-03-04T06:44:56Z")

</div>

Tested on Windows and throw me an error when `npm run algolia`

I’m using .env

```auto
ALGOLIA_APP_ID={{ xxx }}
ALGOLIA_ADMIN_KEY={{ xxx }}
ALGOLIA_INDEX_NAME={{ xxx }}
ALGOLIA_INDEX_FILE={{ public/algolia.json }}

```

```auto
        if (err) throw err
                 ^

Error: ENOENT: no such file or directory, open 'E:\YUDY\WEB PROJECT\TIA\PROD\mm\{{ public\algolia.json }}'
    at Object.fs.openSync (fs.js:663:18)
    at Object.fs.readFileSync (fs.js:568:33)
    at getIndexFromFile (E:\YUDY\WEB PROJECT\TIA\PROD\mm\node_modules\atomic-algolia\lib\utils\getLocalIndex.js:14:27)
    at getLocalIndex (E:\YUDY\WEB PROJECT\TIA\PROD\mm\node_modules\atomic-algolia\lib\utils\getLocalIndex.js:6:16)
    at update (E:\YUDY\WEB PROJECT\TIA\PROD\mm\node_modules\atomic-algolia\lib\update.js:27:24)
    at Object.<anonymous> (E:\YUDY\WEB PROJECT\TIA\PROD\mm\node_modules\atomic-algolia\lib\index.js:15:5)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yes@1.0.0 algolia: `atomic-algolia`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yes@1.0.0 algolia script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yudy\AppData\Local\Webhook\.npm\_logs\2018-03-04T06_37_50_099Z-debug.log

Any idea?

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 4, 2018, 12:28pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/3 "2018-03-04T12:28:45Z")

</div>

Is the error stating {{ public\algolia.json }} or did you do this as a placeholder? if the error states that then the config var is not parsed and should contain the path without {{ }} around. (imho)

I have that article on my todo list and will implement it today or tomorrow and check back if you got yourself sorted out.

---

<div class="post-metadata">

**Author:** ![Yudy\_Ananda](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yudy_ananda/32/5664_2.png) [@Yudy\_Ananda](https://discourse.gohugo.io/u/Yudy_Ananda)\
**Post date:** [March 4, 2018, 12:59pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/4 "2018-03-04T12:59:22Z")

</div>

thanks a lot for remind me, newbie mistake 😅 now `npm run algolia` works like a charm after get rid the brackets.

another problem is I’m stuck in front-end. `<div id="hits">...</div>` displaying all in json. it seems that I have to learn how to display search results.

I hope there will be another tips about on how to display and styling the result.

thanks again

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 4, 2018, 1:11pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/5 "2018-03-04T13:11:58Z")

</div>

you overlooked the link in the end of the article: [https://community.algolia.com/instantsearch.js/v2/getting-started.html](https://community.algolia.com/instantsearch.js/v2/getting-started.html)

I’ll be doing that too in the next days, so just open a thread if there are issues. I am nearly done with “creating” my index… brave new world :D.

---

<div class="post-metadata">

**Author:** ![tcgriffith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tcgriffith/32/7932_2.png) [@tcgriffith](https://discourse.gohugo.io/u/tcgriffith)\
**Post date:** [April 19, 2018, 5:57am UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/6 "2018-04-19T05:57:25Z")

</div>

Thanks a lot for the detailed guide! That’s exacly what I need!

---

<div class="post-metadata">

**Author:** ![papanito](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/papanito/32/13584_2.png) [@papanito](https://discourse.gohugo.io/u/papanito)\
**Post date:** [October 5, 2021, 2:34pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/7 "2021-10-05T14:34:02Z")

</div>

My `.env` file should be correct but I still get this error

```auto
/home/aedu/Workspaces/web/node_modules/atomic-algolia/lib/index.js:16
    if (err) throw err;
             ^

Error: ENOENT: no such file or directory, open '/home/aedu/Workspaces/web/public/algolia.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getIndexFromFile (/home/aedu/Workspaces/web/node_modules/atomic-algolia/lib/utils/getLocalIndex.js:17:25)
    at getLocalIndex (/home/aedu/Workspaces/web/node_modules/atomic-algolia/lib/utils/getLocalIndex.js:9:12)
    at update (/home/aedu/Workspaces/web/node_modules/atomic-algolia/lib/update.js:34:20)
    at Object.<anonymous> (/home/aedu/Workspaces/web/node_modules/atomic-algolia/lib/index.js:13:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/aedu/Workspaces/web/public/algolia.json'

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [October 6, 2021, 2:25pm UTC](https://discourse.gohugo.io/t/searching-hugo-sites-with-algolia/10820/8 "2021-10-06T14:25:26Z")

</div>

Try rebooting your computer.
