Issue: Users need to display different headers on specific pages (typically homepage vs. other pages like a ‘talent’ page) in their Shopify store.
Solution Approach:
Use conditional Liquid code to check the template or page handle
Replace {% include %} with {% section %} for header files
Basic syntax: Check if template equals ‘index’ for homepage, use elsif page.handle == 'talent' for specific pages, and include an else statement for remaining pages
Common Problems:
“Liquid error: Could not find” indicates the header file doesn’t exist or is misnamed
Duplicate headers appearing suggests the default {% section 'header' %} already exists in the theme’s <body> tag and needs to be wrapped in the conditional logic rather than added separately
Users must ensure they’re targeting sections (not snippets) and using correct file names
Key Technical Detail: The default header section typically already exists in the theme layout file, so the conditional logic should replace or wrap that existing code rather than adding new header calls.
Several users report success after switching from include to section and properly structuring the if/elsif/else statements, though newcomers frequently struggle with file placement and naming conventions.
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 %}
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
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
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
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