Need to remove announcement bar from homepage only (keep on shop all/product pages)

Hello,

We are treating our homepage www.qamijan.com as a landing page, and would like to remove the announcement bar from the homepage only.

We have tried editing the theme.liquid as

“{% if template.name != “main-page” %} #shopify-section-announcement-bar { display: none; } {% section “announcement-bar” %}
{% endif %}” but this results in removing the announcement bar from ALL pages, not just the main page/homepage.

Could you please help us?

We are using Label as our theme.

Try this. You need include style inside the if statement

{% if template != 'index'%}

{% endif %}

Thank you. Strangely, this had the opposite effect: it put the announcement bar on the homepage/landing page only and removed it from all other pages. I am seeking to do the vice versa. No announcement on the homepage but on all other pages (shop all, product pages, etc.).

Hi
Just remove !

{% if template == 'index'%}

{% endif %}

Hello @QAMIJAN

In the code editor, you need to modify theme.liquid under the Layout folder.

Navigate > theme.liquid and find the announcement-bar section. Enclose the code like the code below.

{% if template.name != "main-page" %} 
 {% section "announcement-bar" %}
{% endif %}

Thank you. It didn’t work when I pasted that code but I wrote the below instead, in the layout - announcement bar section like you said. THANK YOU!

{% if template == ‘index’%} #shopify-section-announcement-bar { display:none; } {% endif %}

I was pasting it into the wrong part. I put it into the announcement bar section and now it worked. THANK YOU!