# Problems using Algolia with Hugo: javascript and go

**URL:** <https://discourse.gohugo.io/t/problems-using-algolia-with-hugo-javascript-and-go/9636>\
**Category:** support\
**Created:** [December 18, 2017, 6:35pm UTC](https://discourse.gohugo.io/t/problems-using-algolia-with-hugo-javascript-and-go/9636 "2017-12-18T18:35:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pancake](https://avatars.discourse-cdn.com/v4/letter/p/ecd19e/32.png) [@pancake](https://discourse.gohugo.io/u/pancake)\
**Post date:** [December 18, 2017, 6:35pm UTC](https://discourse.gohugo.io/t/problems-using-algolia-with-hugo-javascript-and-go/9636/1 "2017-12-18T18:35:53Z")

</div>

I am trying to use Algolia to build search on my site. I have created a hitTemplate to use with instantsearch.js which I’ve placed in `/js/search.js`, which looks like this:

```
var hitTemplate =
  '<div class="hit>' +
    '<div>' +
      '<a class="{{if eq .Params.highlight "true"}} red{{end}}" href="{{website}}">' +
        '<h1>{{title}}</h1>' +
        '<h2>{{description}}</h2>' +
        '<ul>' +
          '<li>{{locations}}</li>' +
        '</ul>' +
      '</a>' +
    '</div>' +
  '</div>'

```

The problem I am having is mixing Hugo code with Algolia’s javascript. Any Hugo code in search.js will not generate. If I place the template in index.html, Algolia’s javascript won’t work. How do I combine the two?

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [December 18, 2017, 8:44pm UTC](https://discourse.gohugo.io/t/problems-using-algolia-with-hugo-javascript-and-go/9636/2 "2017-12-18T20:44:20Z")

</div>

There are more than a few [discussions about implementing Algolia in Hugo](https://discourse.gohugo.io/search?q=algolia). You might consider reading through those and looking at their repos to see how they implemented it.

Depending on where your “hitTemplate” lives, you either need to have Hugo generate the JavaScript as a custom output, or generate the script in an HTML doc and make sure to pass everything through safe filters. In either case, please refer to the [docs](https://gohugo.io/documentation/) and the post about [requesting help](https://discourse.gohugo.io/t/requesting-help/9132?u=maiki). 🙂

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [December 18, 2017, 8:57pm UTC](https://discourse.gohugo.io/t/problems-using-algolia-with-hugo-javascript-and-go/9636/4 "2017-12-18T20:57:40Z")

</div>

> [@pancake](#):
>
> For the record, I’ve been looking through the docs and reading the threads. I still haven’t managed to get it to work that’s why I asked…

I don’t understand this response. Is it defensive? I gave you three distinct options, with links. Is there something in the way I said it that was dismissive or patronizing?
