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?