Hubspot and Template Implementation

Hey Algolia community-

I’m trying to get a search query to populate from the search box on every page and show results on a single results page. I have most of the code - it works when hosting it locally on my machine - but when I go to implement in Hubspot the result values are missing. For some reason Hubspot does not like the {{{ }}} coding.

Here is my code:

image

Here’s what is displayed for search results:

Hi,

To achieve what you want, you need to escape the HubSpot delimiters {{}} like this:

search.addWidget(
  instantsearch.widgets.hits({
    templates: {
      hits: {% raw %}'text and {{{some_variable}}}'{% endraw %}
    }
  })
);

Anytime you need to have {{ or {{{ being written as it in your JavaScript code then you need to escape it otherwise HubSpot will try to interact with it.

Here’s the documentation for this: https://designers.hubspot.com/docs/hubl/intro-to-hubl#escaping-hubl-delimiters

Thanks for using Algolia!

1 Like

That worked perfect. Thanks so much for the guidance.