How to show menu items in Shopify?

expoundsofttechsolution How to show menu items in Shopify?

1. From your Shopify admin, go to Online Store and click on Navigation.

2. Click on the Title of the menu which you want to edit.

3. After choosing the title, you will see the menu item section, then click on Add menu item button.

4. Enter the title for the menu item in the Name field and then click on the Link field and select the link for the menu item.

5. Click on Add button and close the Add menu item pop-up box.

6. Click on the Save button to finish.

7. Paste the below code in the Sections/header.liquid file or where you want to display the navigation.

<nav class="navbar" role="navigation">
  <ul>
    {%- for link in linklists.main-menu.links -%}
      <li>
        <a href="{{ link.url }}" {% if link.active %}aria-current="page"{% endif %}>
          {{ link.title }}
        </a> 
      </li>
    {%- endfor -%}
  </ul>
</nav>

8. If you want to show sub-menu items with main menu items then use this code.

<nav class="navbar" role="navigation">
  <ul>
    {%- for link in linklists.main-menu.links -%}
      <li>
        <a href="{{ link.url }}" {% if link.active %}aria-current="page"{% endif %}>
          {{ link.title }}
        </a>

        {%- if link.links != blank -%}
          <ul>
            {%- for child_link in link.links -%}
              <li>
                <a href="{{ child_link.url }}" {% if child_link.active %}aria-current="page"{% endif %}>
                  {{ child_link.title }}
                </a>
              </li>
            {%- endfor -%}
          </ul>
        {%- endif -%}

      </li>
    {%- endfor -%}
  </ul>
</nav>

How to show menu items in Shopify?