How to Add and Edit Breadcrumbs in Shopify
I'm obviously not talking about this kind of breadcrumbs
- 7 min read

How to Add and Edit Breadcrumbs in Shopify

On this page
Introduction

The most important thing to consider when trying to improve the experience of the customers shopping on your Shopify store is your site navigation.

Now, most Shopify Merchants and customers know that every Shopify store (and website in general) is going to have the main navigation at the top of the page. But something you might not have considered is if your site needs to be making use of breadcrumb navigation.

💡
According to the Nielsen Norman Group, which is a group of world-renowned experts in User Experience, breadcrumbs are an important navigational element that supports wayfinding — making users aware of their current location within the hierarchical structure of a website. Breadcrumbs are a list of links representing the current page and its “ancestors” (parent page, grandparent page, and so on), typically going all the way back to the site homepage.

If that explanation was a little too wordy for you, it essentially says that breadcrumbs are a form of navigation that will make your customers aware of their current location inside your Shopify store and provide them a bunch of links they can use to go to previous pages connected to the page they are viewing.

Breadcrumbs can be really helpful in the following situations:

  • Your Shopify website has a bunch of pages, a lot of inventory, and site navigation that might go more than two or three levels deep
  • A potential customer enters your Shopify store from a search on Google or a link from a social media site that does not lead them to the home page

Check out this example below of a Shopify Store that uses breadcrumbs in its collections pages to provide a better user experience to customers.

An example of a Shopify store that uses breadcrumbs to make customers aware of where they are when navigating through collections and subcollections
This a screenshot from The Modern Shop which uses breadcrumbs in the collections page to help customers figure out where they are in the store as they navigate collections and subcollections 

Now let's say that you clicked a link from the Shopify store in the example above and it lead you to the page in the image. Underneath the header and the main navigation, you can see the following:

Home > Accessories > Coffee & Tea

This lets you know that you are on a page that is showing you a sub-collection of products from their Accessories collection. Now I'm sure that most customers could probably figure this out just by staring at the page for long enough but a good user experience should answer the question of "where am I right now?" without the customer even having to think about it.

I know it seems like a small thing but it is little things like this that can put the customer at ease and increase the likelihood of them opting into an email list or just straight up buying one of your products.

So now that you know what breadcrumbs are and how they can be helpful, let's talk about how you add them to your Shopify 2.0 Theme for free.

Adding Breadcrumbs to Your Theme for Free

Below I've placed a bunch of blocks of code as well as a video that will show you the step-by-step process you can follow to add this to your theme.

I've also placed a "copy" button at the top right of each block of code that you can use to copy all the code for that block to your clipboard.

I recommend using that to copy the code you need instead of highlighting the whole thing yourself

Code For Breadcrumb.liquid

This is the code you will be adding to a new file in your snippets folder called breadcrumb.liquid

{%- style -%}
    .breadcrumbs {
        padding: 1rem 2rem;
        color: {{ settings.breadcrumb_text_color }};
    }

    .breadcrumbs li {
        display: inline-block;
    }

    .breadcrumbs a {
        text-decoration: none;
        /*Will put liquid customization here*/
        font-size: 15px;
        color: inherit;
    }

    .breadcrumb-delimeter:not(:last-child):after {
        {%- if settings.breadcrumb_delimeter == "angle_right" -%}
            content: "›";
            font-size: 18px;
        {%- elsif settings.breadcrumb_delimeter == "slash" -%}
            content: "/";
            font-size: 16px;
        {%- endif -%}
        display: inline-block;
        margin-left: .75rem;
        margin-right: 0.50rem;
        speak: none;
    }

    .breadcrumbs [aria-current="page"] {
        color: inherit;
        font-weight: normal;
        text-decoration: none;
    }

    
{%- endstyle -%}



<div class="breadcrumbs" aria-label="breadcrumbs">
    {%- unless template == 'index' or template == 'cart' -%}
    <a href="/" title="Home">Home</a>
    {%- case template.name -%}
        {%- when 'article' -%}
        {%- for link in linklists.main-menu.links -%}
            {%- if link.url == blog.url -%}
                <span class = "breadcrumb-delimeter" aria-hidden="true"></span> <!--Breadcrumb Delimeter -->
                {{ link.title | link_to: link.url }}
                {% break %}
            {%- endif -%}
        {%- endfor -%}
            <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
            <a href="{{ article.url }}" aria-current="page">{{ article.title }}</a>
        {%- when "product" -%}
            {%- capture product_url_string -%}
            {%- for collection in product.collections -%}
                {{collection.url }}|
            {%- endfor -%}
            {%- endcapture -%}
    
            {%- assign object_url_string = product_url_string | append: product.url -%}
        
            {%- assign object_urls = object_url_string | split: '|' -%}
            {%- capture linklist_titles_str -%}{%- for linklist in linklists -%}{{ linklist.title | handleize }}|{%- endfor -%}{%- endcapture -%}
            {%- assign str_size = linklist_titles_str | size | minus: 1 -%}
            {%- assign linklist_titles_str = linklist_titles_str | slice: 0, str_size -%}
            {%- assign linklist_titles = linklist_titles_str | split: '|' -%}
        
        
        {%- assign level = 1 -%}
        {%- for link in linklists.main-menu.links -%}
            {%- assign link_handle = link.title | handle -%}
            {%- assign link_titles = link_titles | append: link.title | append: '|' -%}
            {%- assign link_urls = link_urls | append: link.url | append: '|' -%}
            {%- assign link_levels = link_levels | append: level | append: '|'  -%}
            {%- assign link_parents = link_parents | append: 'main-menu' | append: '|'  -%}
            {%- assign link_handles = link_handles | append: link_handle | append: '|' -%}
        
            {%- if linklist_titles contains link_handle -%} 
        
            {%- for clink in linklists[link_handle].links -%}
                {%- if forloop.first == true -%}
                {%- assign level = level | plus: 1 -%}
                {%- endif -%}
                {% assign clink_handle = clink.title | handle %}
                {%- assign link_titles = link_titles | append: clink.title | append: '|' -%}
                {%- assign link_urls = link_urls | append: clink.url | append: '|' -%}
                {%- assign link_levels = link_levels | append: level | append: '|'  -%}
                {%- assign link_parents = link_parents | append: link_handle | append: '|'  -%}
                {%- assign handle = link.title | handleize -%} 
                {%- assign link_handles = link_handles | append: clink_handle | append: '|' -%}
        
                {%- if linklist_titles contains clink_handle -%}
        
                    {%- for gclink in linklists[clink_handle].links -%}
                        {%- if forloop.first == true -%}
                        {%- assign level = level | plus: 1 -%}
                        {%- endif -%}
        
                        {% assign gclink_handle = gclink.title | handle %}
                        {%- assign link_titles = link_titles | append: gclink.title | append: '|' -%}
                        {%- assign link_urls = link_urls | append: gclink.url | append: '|' -%}
                        {%- assign link_levels = link_levels | append: level | append: '|'  -%}
                        {%- assign link_parents = link_parents | append: gclink_handle | append: '|'  -%}
                        {%- assign link_handles = link_handles | append: gclink_handle | append: '|' -%}

                        {%- if forloop.last == true -%}
                        {%- assign level = level | minus: 1 -%}
                        {%- endif -%}
                    {%- endfor -%}
        
                {%- endif -%}
                {%- if forloop.last == true -%}
                {%- assign level = level | minus: 1 -%}
                {%- endif -%}
            {%- endfor -%}
            {%- endif -%}
        {%- endfor -%}
        
        {%- comment -%} CONVERT TO ARRAYS {%- endcomment -%}
        {%- assign str_size = link_levels | size | minus: 1 -%}
        {%- assign llevels = link_levels | slice: 0, str_size | split: '|' -%}
        
        {%- assign str_size = link_titles | size | minus: 1 -%}
        {%- assign ltitles = link_titles | slice: 0, str_size | split: '|' -%}
        
        {%- assign str_size = link_handles | size | minus: 1 -%}
        {%- assign lhandles = link_handles | slice: 0, str_size | split: '|' -%}
        
        {%- assign str_size = link_parents | size | minus: 1 -%}
        {%- assign lparents = link_parents | slice: 0, str_size | split: '|' -%}
        
        {%- assign str_size = link_urls | size | minus: 1 -%}
        {%- assign lurls = link_urls | slice: 0, str_size | split: '|' -%}
        
        {%- assign depth = '3' -%}
        {%- assign bc3_parent_list_handle = '' %}
        
        {%- for url in lurls -%}
            {%- if object_urls contains url and llevels[forloop.index0] == depth -%}
            {%- unless url == product.url or url == collection.url -%}
                {%- capture bc3 -%}{{ ltitles[forloop.index0] | link_to: url, ltitles[forloop.index0] }}{%- endcapture -%}
            {%- endunless -%}
            {%- assign bc3_parent_list_handle = lparents[forloop.index0] -%}
            {%- assign bc3_list_handle = lhandles[forloop.index0] -%}
            {% break %}
            {%- endif -%}
        {%- endfor -%}

        {%- assign depth = '2' -%}
        {%- assign bc2_parent_list_handle = '' %}
        
        {%- if bc3_parent_list_handle == '' -%} 
            {%- for url in lurls -%}
            {%- if llevels[forloop.index0] == depth -%}
                {%- if object_urls contains url -%} 
                {%- unless url == product.url or url == collection.url -%}
                    {%- capture bc2 -%}{{ ltitles[forloop.index0] | link_to: url, ltitles[forloop.index0] }}{%- endcapture -%}
                {% endunless %}
                {%- assign bc2_parent_list_handle = lparents[forloop.index0] -%}
                {%- break -%}
                {%- endif -%}
            {%- endif -%}
            {%- endfor -%} 
        {%- else -%}

            {%- for list_handle in lhandles -%}
            {%- if list_handle == bc3_parent_list_handle -%}
                {% assign bc2_list_handle = list_handle %}
                {%- assign bc2_parent_list_handle = lparents[forloop.index0] -%}
                {%- assign bc2_list_title = ltitles[forloop.index0] -%}
                {%- for bc2_sibling_link in linklists[bc2_parent_list_handle].links -%}
                {%- assign bc2_sibling_title_handleized = bc2_sibling_link.title | handle -%}
                {% if bc2_sibling_title_handleized == bc2_list_handle %}
                    {%- capture bc2 -%}{{ bc2_sibling_link.title | link_to: bc2_sibling_link.url, bc2_sibling_link.title }}{%- endcapture -%}
                    {% break %}
                {%- endif -%}
                {%- endfor -%}
                {% break %}
            {%- endif -%}
            {%- endfor -%}
        {%- endif -%}
        
        {%- assign depth = depth | minus: 1 | append: '' -%}
        {%- assign bc1_parent_list_handle = '' %}
        
        {%- if bc2_parent_list_handle == '' -%} 
            {% for url in lurls %}
            {%- if object_urls contains url and llevels[forloop.index0] == depth -%}
                {%- unless url == product.url or url == collection.url -%}
                {%- capture bc1 -%}{{ ltitles[forloop.index0] | link_to: url, ltitles[forloop.index0] }}{%- endcapture -%}
                {% endunless %}
                {%- assign bc1_parent_list_handle = lparents[forloop.index0] -%}
                {%- break -%}
            {%- endif -%}
            {%- endfor -%}
        
        {%- else -%}
            {%- for list_handle in lhandles -%}
            {%- if bc2_parent_list_handle == list_handle -%}
                {% assign bc1_list_handle = list_handle %}
                {%- assign bc1_parent_list_handle = lparents[forloop.index0] -%}
                {%- assign bc1_title = ltitles[forloop.index0] -%}
                {%- for bc1_sibling_link in linklists[bc1_parent_list_handle].links -%}
                {%- assign bc1_sibling_title_handleized = bc1_sibling_link.title | handle -%}
                {% if bc1_sibling_title_handleized == bc1_list_handle %}
                    {%- capture bc1 -%}{{ bc1_sibling_link.title | link_to: bc1_sibling_link.url, bc1_sibling_link.title }}{%- endcapture -%} 
                    {% break %}
                {%- endif -%}
                {%- endfor -%}
            {%- endif -%}
            {%- endfor -%}
        {%- endif -%}
       
            {%- if bc1 -%}
            <span class = "breadcrumb-delimeter" aria-hidden="true"></span> <!--Breadcrumb Delimeter -->
            {{ bc1 }}
            {%- endif -%}
            {%- if bc2 -%}
            <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
            {{ bc2 }}
            {%- endif -%}
            {%- if bc3 -%}
            <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
            {{ bc3 }}
            {%- endif -%}
        
            <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
            <a href = "{{ product.url }}">{{ product.title }}</a>
        {%- else -%}
            {% for link in linklists.main-menu.links %}
                {% if link.child_active or link.active %}
                <span class = "breadcrumb-delimeter" aria-hidden="true"></span> <!--Breadcrumb delimeter-->
                    <a href="{{ link.url }}">
                    {{ link.title | escape }}  
                    </a>
                    {% for clink in link.links %}
                    {% if clink.child_active or clink.active %}
                    <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
                        <a href="{{ clink.url }}">
                        {{ clink.title | escape }} 
                        </a>
                        {% for gclink in clink.links %}
                        {% if gclink.child_active or gclink.active %}
                            <span class = "breadcrumb-delimeter" aria-hidden="true"></span>
                            <a href="{{ gclink.url }}">
                            {{ gclink.title | escape }} 
                            </a>
                        {% endif %}
                        {%- endfor -%}
                    {% endif %}
                    {%- endfor -%}
                {% endif %}
            {%- endfor -%}
        {%- endcase -%}
    {%- endunless -%}
</div>

<script defer>
    const breadCrumbLinks = document.querySelectorAll(".breadcrumbs a")
    const lastLink = breadCrumbLinks[breadCrumbLinks.length - 1]
    lastLink.href = "javascript:void(0)"
</script>

Code To Put in Settings Schema

The snippet of code below is what you will be adding to the settings_schema.json file in your theme's config folder. Make sure you include the opening and closing bracket around the code `{ }` so that the code editor does not trigger an error.

{
    "name": "Breadcrumb Navigation",
    "settings": [
      {
        "type": "checkbox",
        "id": "show_breadcrumb_nav",
        "label": "Show breadcrumb navigation",
        "default": true
      },
      {
        "type": "select",
        "id": "breadcrumb_delimeter",
        "info":"The icon that is between every link in the breadcrumb",
        "label": "Breadcrumb Delimeter Icon",
        "options": [
          {
            "value": "angle_right",
            "label": "Angle Right"
          },
          {
            "value": "slash",
            "label": "Slash"
          }
        ],
        "default": "angle_right"
      },
      {
        "type": "color",
        "id": "breadcrumb_text_color",
        "label": "Breadcrumb Color",
        "default": "#465076"
      }
    ]
  }

Code To Put in Theme.liquid

{%- if settings.show_breadcrumb_nav -%}
    {% render "breadcrumbs.liquid" %}
{%- endif -%}

Wrapping Up

So that about does it.

If you've gotten to this point and followed the tutorial instructions, you should now have a working breadcrumb component in your Shopify Theme.

In the video above I said I would give you access to a members-only tutorial that would show you how you can update your breadcrumbs to give you more customization options.

This is the kind of thing that you'd have to pay a developer to make for you but I'm giving it away because I want you to know I'm serious about helping you create a better user experience on your Shopify store.

Get Access to it Below ⬇️