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

Marb
Tourist
3 0 2

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.

Replies 3 (3)

Marb
Tourist
3 0 2

Solved w/ Custom liquid in theme editor

KetanKumar
Shopify Partner
36844 3636 11978

@Marb 

yes please try this way

{% if template contains 'index' %}
  your custom script 
{% endif %}
If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
alantabs
Visitor
3 0 0

Where do you pace this? Just before  </body> in theme.liquid?