Shopify themes, liquid, logos, and UX
I want different Menus on different Pages in my Shopify Store but my code doesn't work. If i use my code it shows me no menu also the mainmenu is not visible.
I created a Page and a Page Template
I code this at the top of the file header-drawer.liquid after comment
{% if page.handle contains == "PageTemplateName" %} {% assign _new_menu = linklists.HandleMenuName.links %} {% else %} {% assign _new_menu = section.settings.menu.links %} {% endif %}>
And i replace on line 10 {%- for link in section.settings.menu.links -%} with {%- for link in section._new_menu -%}
After that i repeat the steps with header-dropdown-menu.liquid and header-mega-menu.liquid
@findfy page handle gets page name in the url, is your page name "PageTemplateName" , please check in url
Hello @findfy
Your code has a couple of syntax errors and logical issues. Here’s how you can properly implement different menus for different pages in your Shopify store:
Fixes & Corrections:
Remove extra == in the if statement
Correct the assignment of the new menu
Use the correct way to reference the link list
Corrected Code for header-drawer.liquid
{% if page.handle == "PageTemplateName" %}
{% assign _new_menu = linklists.HandleMenuName.links %}
{% else %}
{% assign _new_menu = section.settings.menu.links %}
{% endif %}
{%- for link in _new_menu -%}
<li>
<a href="{{ link.url }}">{{ link.title }}</a>
</li>
{%- endfor -%}
Key Fixes:
Removed contains ==, which was incorrect. Instead, use == for exact matches or contains for partial matches.
Removed section._new_menu, since _new_menu is a variable, not part of the section object.
For header-dropdown-menu.liquid & header-mega-menu.liquid
Repeat the same logic in those files where you loop through the menu.
Let me know if you need further refinements!
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025