How to Add a Second Menu to Your Shopify Store Header

Published on Aug 15, 2024

By Michael Chen

#Shopify#E-commerce#Web Development
Free stock photo of adolescent, adult, blur

Are you looking to enhance your Shopify store’s navigation by adding a second menu to your header? This guide will walk you through the process, providing step-by-step instructions and tips to help you customize your store’s header effectively.

Understanding the Need for a Second Menu

Improving Navigation

Adding a second menu to your Shopify header can significantly improve your store’s navigation. It allows you to organize your content more efficiently, making it easier for customers to find what they’re looking for.

Enhancing User Experience

A well-structured header with multiple menus can enhance the overall user experience. It provides more options for customers to explore your store without cluttering the main navigation.

Showcasing Important Links

With a second menu, you can highlight important links or categories that might otherwise get lost in a single, crowded menu.

Adding a Second Menu to Your Shopify Header

Accessing Your Theme Files

To add a second menu to your header, you’ll need to edit your theme files. Here’s how to do it:

  1. Go to your Shopify admin panel
  2. Navigate to “Online Store” > “Themes”
  3. Click on “Edit code” for your current theme

Modifying the Header Liquid File

Once you’re in the theme editor, follow these steps:

  1. Locate and open the header.liquid file
  2. Find the section where the main menu is defined
  3. Add the following code snippet below the main menu:
{%- if linklists.legal.links != blank -%}
<nav class="header__inline-menu">
  <ul class="list-menu list-menu--inline" role="list">
    {%- for link in linklists.legal.links -%}
      <li>
        {%- if link.links != blank -%}
          <header-menu>
            <details id="Details-HeaderMenu-{{ forloop.index }}" class="mega-menu">
              <summary class="header__menu-item list-menu__item link focus-inset">
                <span {%- if link.child_active %} class="header__active-menu-item"{% endif %}>{{ link.title | escape }}</span>
                {% render 'icon-caret' %}
              </summary>
              <div id="MegaMenu-Content-{{ forloop.index }}" class="mega-menu__content gradient motion-reduce global-settings-popup" tabindex="-1">
                <ul class="mega-menu__list page-width{% if link.levels == 1 %} mega-menu__list--condensed{% endif %}" role="list">
                  {%- for childlink in link.links -%}
                    <li>
                      <a href="{{ childlink.url }}" class="mega-menu__link mega-menu__link--level-2 link{% if childlink.current %} mega-menu__link--active{% endif %}"{% if childlink.current %} aria-current="page"{% endif %}>
                        {{ childlink.title | escape }}
                      </a>
                      {%- if childlink.links != blank -%}
                        <ul class="list-unstyled" role="list">
                          {%- for grandchildlink in childlink.links -%}
                            <li>
                              <a href="{{ grandchildlink.url }}" class="mega-menu__link link{% if grandchildlink.current %} mega-menu__link--active{% endif %}"{% if grandchildlink.current %} aria-current="page"{% endif %}>
                                {{ grandchildlink.title | escape }}
                              </a>
                            </li>
                          {%- endfor -%}
                        </ul>
                      {%- endif -%}
                    </li>
                  {%- endfor -%}
                </ul>
              </div>
            </details>
          </header-menu>
        {%- else -%}
          <a href="{{ link.url }}" class="header__menu-item list-menu__item link link--text focus-inset"{% if link.current %} aria-current="page"{% endif %}>
            <span {%- if link.current %} class="header__active-menu-item"{% endif %}>{{ link.title | escape }}</span>
          </a>
        {%- endif -%}
      </li>
    {%- endfor -%}
  </ul>
</nav>
{%- endif -%}

Customizing the Second Menu

To customize your second menu:

  1. Replace linklists.legal.links with the handle of your desired menu (e.g., linklists.footer.links for a footer menu)
  2. Adjust the CSS classes and styles to match your theme’s design

Styling Your New Menu

Adding Custom CSS

To ensure your new menu fits seamlessly with your existing design, you may need to add some custom CSS. Here’s an example:

<style>
  .second-menu {
    /* Add your custom styles here */
    margin-top: 10px;
  }
  
  .second-menu .list-menu {
    display: flex;
    justify-content: center;
  }
  
  .second-menu .list-menu__item {
    margin: 0 10px;
  }
</style>

Responsive Design Considerations

When adding a second menu, it’s crucial to consider how it will appear on different devices. You may want to add media queries to adjust the layout for mobile screens:

@media screen and (max-width: 749px) {
  .second-menu {
    display: none; /* Hide on mobile if desired */
  }
  
  /* Or adjust layout for mobile */
  .second-menu .list-menu {
    flex-direction: column;
  }
}

Troubleshooting Common Issues

Menu Not Appearing

If your second menu isn’t showing up, check the following:

  1. Ensure you’ve created the menu in your Shopify admin (Online Store > Navigation)
  2. Verify that you’re using the correct menu handle in your liquid code
  3. Check for any JavaScript errors in your browser console

Styling Conflicts

If the new menu doesn’t look right:

  1. Inspect the elements using your browser’s developer tools
  2. Adjust the CSS to override any conflicting styles
  3. Consider adding more specific CSS selectors to target your new menu

Conclusion

Adding a second menu to your Shopify header can greatly improve your store’s navigation and user experience. By following this guide, you should be able to implement and customize an additional menu that fits seamlessly with your store’s design. Remember to test your changes thoroughly across different devices to ensure a consistent experience for all your customers.

For more advanced customizations or if you encounter any issues, consider consulting Shopify’s official documentation at https://shopify.dev/themes or reaching out to a Shopify Expert for assistance.

Take Our Quick Quiz:

Which primary product image do you think has the highest conversion rate?