How can I add code to the header of the homepage?

How can I add code to the header of the homepage?

NQuan088
Shopify Partner
6 0 0

Hello everyone ! I have a piece of HTML code. I want to attach it to the header of the homepage. Home page only. I found the header.liquid file but it seems to show up on the whole website. Can someone help me with this problem?
Thanks everyone!

Replies 3 (3)

GemPages
Shopify Partner
5625 1262 1279

Hello @NQuan088 

 

You can add code to the header.liquid like this

{% if template contains 'index' %}
//Your code here
{% endif %}

 

I hope the above is useful to you.


Kind & Best regards, 
GemPages Support Team

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center

Simonsron
Shopify Partner
699 87 123

You can be in the  [edit code => layout=> theme.liquid]   add

{% if template.name == "index" %}
       //your code here....
{%endif%}

 

banned
NQuan088
Shopify Partner
6 0 0

I did it. Thank you very much ❤️