Re: Change header in 2 different pages.

Solved

How can I modify headers on specific pages?

FreddDrummer
Tourist
11 0 0

Hi ShopiComunity,... i need help. 
I need change the header in 2 pages (index and talent) but no work.. 😕 

My code: 
{% if template == 'index' %}
{% include 'header' %}
{% elsif pages == 'talent' %}
{% include 'header-talent' %}
{% else %}
{% endif %}

Please,...

Thank ^^

Accepted Solution (1)
Robert_Chen
Explorer
72 3 12

This is an accepted solution.

{% if template == 'index' %}
 {% section 'header' %}
{% elsif page.handle == 'talent' %}
{% section 'header-talent' %}
{% else %}
{% section 'header-for-other-pages' %}
{% endif %}

try this

View solution in original post

Replies 14 (14)

AmardeepSingh
Shopify Partner
94 5 15

Hi Fredd,

I assume "talent" is the handle of the page. Can you try this? Make sure to include header in the last else statement for pages other than Index & talent. I have added a dummy include statement. If you think there shouldn't be anything, you may safely remove this line :

"{% include 'header-for-other-pages' %}"

 

 

{% if template == 'index' %}
{% include 'header' %}
{% elsif page.handle == 'talent' %}
{% include 'header-talent' %}
{% else %}

{% include 'header-for-other-pages' %}
{% endif %}

FreddDrummer
Tourist
11 0 0

Hi, thank..but nothing yet 😕 

Text n header index (pages 1) and Talent (pages 2): 

"Liquid error: Could not find asset snippets/header.liquid"


Look my code page.jpg

 

😕 

Robert_Chen
Explorer
72 3 12

This is an accepted solution.

{% if template == 'index' %}
 {% section 'header' %}
{% elsif page.handle == 'talent' %}
{% section 'header-talent' %}
{% else %}
{% section 'header-for-other-pages' %}
{% endif %}

try this

FreddDrummer
Tourist
11 0 0

Hi All ¡

Thank you ¡

Amar3, Robert_Chen, Jason: are awesome ¡¡ lml ^^ lml

2 headers with different design and text ^^

it works 🙂 

Stu_1984
New Member
4 0 0

Doesn't work for me.

Getting two header sections appear on top of each other on every page. Seems like the If/else statement isn't working. I've tried as above and that didn't work and tried below and that doesnt work either. Any help would be appreciated

{% if page.handle == 'index' %}
{% section 'header' %}
{% else %}
{% section 'header-two' %}
{% endif %}

alx_noa
Visitor
2 0 1

Hi There! 

 

 

Doleey
Visitor
2 0 0

{% section 'header' %} already exists by default in the  <body>

Search for it and then wrap your if-else statement around that code to avoid duplication. 

myselfvarun
Visitor
2 0 0

Hi I am facing the same problem but I am new to Shopify, can to please tell me where to add this code and what file name should I give to the other header file

CC_01
Visitor
1 0 0

Hi, I know it has been a couple of years but I'm hoping you can help please. I'm a bit stuck with this. I'm getting two headers on top of each other, and they are the same header. I'm not sure why though

alishahzad
Shopify Partner
14 0 4

Best solution

Muhammad Ali
Amna4
Visitor
2 0 0

Hello. Where am I supposed to put this code?

Amna4
Visitor
2 0 0

Hi Robert. I want to keep a different header for my home page on my website. I tried this but didn't work. Attaching a link of my store for reference. Could you also tell me where to put the code. I am new to shopify

www.wearazulie.com

Jason
Shopify Partner
11207 226 2318

The error you're seeing is letting you know that the snippet file - called "header.liquid" - doesn't exist.

In that content you want to include, what is the filename?

 

[edit] Robert could very well be on the right path of thinking here if it's not a snippet at all but instead a section.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
AmardeepSingh
Shopify Partner
94 5 15

Fredd,

Try these 2 things - 

 

1. Replace 'include' with 'section' & see how it goes.

2. As Jason said, create those file with appropriate HTML & Liquid & it should work.

 

Thanks