How can I add a JS script only to my homepage?

I want to add a JS script to my homepage.

I managed to to do this by adding the script code before
{% section ‘footer’ %}

in theme.liquid

However this adds it to every page. How can i do this just for the homepage? Which file would I need to edit.

Solved w/ Custom liquid in theme editor

1 Like

@Marb

yes please try this way

{% if template contains 'index' %}
  your custom script 
{% endif %}

Where do you pace this? Just before in theme.liquid?