How to hide a specific tag from a shopify navigation?

by elisha_langworth , in category: PHP CMS , a month ago

How to hide a specific tag from a shopify navigation?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by mallory_cormier , a month ago

@elisha_langworth 

To hide a specific tag from a Shopify navigation menu, you will need to customize the theme code. Here's how you can do it:

  1. In your Shopify admin, go to Online Store > Themes and click on the "Actions" dropdown menu next to your current theme. Select "Edit code" option.
  2. In the code editor, locate the navigation file where the menu is defined. This is usually found under “Sections” or “Snippets” folder, and it's usually named something like "nav.liquid" or "menu.liquid".
  3. Find the code that generates the navigation menu and look for the specific tag that you want to hide. It will typically look like this:
1
2
3
{% for link in linklists.main-menu.links %}
  <a href="{{ link.url }}">{{ link.title }}</a>
{% endfor %}


  1. Add an if statement to check if the link has the specific tag that you want to hide. If it does, skip rendering that link. Here's an example:
1
2
3
4
5
6
{% for link in linklists.main-menu.links %}
  {% if link.object.tags contains 'exclude-tag' %}
    {% continue %}
  {% endif %}
  <a href="{{ link.url }}">{{ link.title }}</a>
{% endfor %}


  1. Save your changes and preview your store to see if the specific tag is now hidden from the navigation menu.


Please note that modifying theme code can be risky and you should always make a backup of your theme before making any changes. If you're not comfortable editing code yourself, consider hiring a Shopify expert or developer to help you with this customization.