Shopify themes, liquid, logos, and UX
Follow these steps to configure different header menus (header-mega-menu, header-dropdown-menu, header-drawer) based on different page templates and collections in your Shopify store.
In each of the files listed above, locate the beginning of the file.
Insert the following code at the top of each file to handle different templates:
Replace "collectiontemplate" with the page or collection page assigned name, found on the top of the editor.
{% if template.suffix == "collectiontemplate1" or
template.suffix == "collectiontemplate2" or
template.suffix == "collectiontemplate3" or
template.suffix == "collectiontemplate4" or
template.suffix == "collectiontemplate5" or
template.suffix == "collectiontemplate6" or
template.suffix == "collectiontemplate7" %}
{% assign _new_menu = linklists.handle.links %}
{% else %}
{% assign _new_menu = section.settings.menu.links %}
{% endif %}
In each file, locate the loop that iterates over the menu links. It might look something like this:
{%- for link in section.menu.links -%}
Replace that line with the following to use the newly assigned _new_menu:
{%- for link in _new_menu -%}
This approach allows you to tailor your site's navigation experience based on the content or design of individual pages and collections, enhancing usability and design consistency.
Example:
Solved! Go to the solution
This is an accepted solution.
Follow these steps to configure different header menus (header-mega-menu, header-dropdown-menu, header-drawer) based on different page templates and collections in your Shopify store.
In each of the files listed above, locate the beginning of the file.
Insert the following code at the top of each file to handle different templates:
Replace "collectiontemplate" with the page or collection page assigned name, found on the top of the editor.
{% if template.suffix == "collectiontemplate1" or
template.suffix == "collectiontemplate2" or
template.suffix == "collectiontemplate3" or
template.suffix == "collectiontemplate4" or
template.suffix == "collectiontemplate5" or
template.suffix == "collectiontemplate6" or
template.suffix == "collectiontemplate7" %}
{% assign _new_menu = linklists.handle.links %}
{% else %}
{% assign _new_menu = section.settings.menu.links %}
{% endif %}
In each file, locate the loop that iterates over the menu links. It might look something like this:
{%- for link in section.menu.links -%}
Replace that line with the following to use the newly assigned _new_menu:
{%- for link in _new_menu -%}
This approach allows you to tailor your site's navigation experience based on the content or design of individual pages and collections, enhancing usability and design consistency.
Example:
Thank you, but I just posted the solution to the problem. I think I posted on the wrong place :-V
This is an accepted solution.
Follow these steps to configure different header menus (header-mega-menu, header-dropdown-menu, header-drawer) based on different page templates and collections in your Shopify store.
In each of the files listed above, locate the beginning of the file.
Insert the following code at the top of each file to handle different templates:
Replace "collectiontemplate" with the page or collection page assigned name, found on the top of the editor.
{% if template.suffix == "collectiontemplate1" or
template.suffix == "collectiontemplate2" or
template.suffix == "collectiontemplate3" or
template.suffix == "collectiontemplate4" or
template.suffix == "collectiontemplate5" or
template.suffix == "collectiontemplate6" or
template.suffix == "collectiontemplate7" %}
{% assign _new_menu = linklists.handle.links %}
{% else %}
{% assign _new_menu = section.settings.menu.links %}
{% endif %}
In each file, locate the loop that iterates over the menu links. It might look something like this:
{%- for link in section.menu.links -%}
Replace that line with the following to use the newly assigned _new_menu:
{%- for link in _new_menu -%}
This approach allows you to tailor your site's navigation experience based on the content or design of individual pages and collections, enhancing usability and design consistency.
Example:
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024