Add 'Page' To Breadcrumbs Navigation

New Member
1 0 0

Hello, I'm hoping there is a quick fix, woth a try, thanks.

I've created a collection subset on a page template.

After creation current breadcrumb behavior is:

Home>Page

Then when a collection on this page is clicked it turns to

Home>Collection

As you can see it excludes the previous page in its breadcrumb capture.

I am hoping for:

Home>Page>Collection>Product

Anyone know what code and where I need to add to breadcrumb.liquid below to achieve this? Thaks in advance.

{% include 'advanced-tag-loop' %}

{% unless template.name == 'index' or template.name == 'cart' %}
<nav class="breadcrumb" role="navigation" aria-label="breadcrumbs">
  <a href="/" title="{{ 'general.breadcrumbs.home_link_title' | t }}">{{ 'general.breadcrumbs.home' | t }}</a>

  {% if template.name == 'product' %}

    {% if collection %}
      <span class="divider" aria-hidden="true">&rsaquo;</span>
      {% if collection.handle %}
        {% capture url %}/collections/{{ collection.handle }}{% endcapture %}
        {{ collection.title | link_to: url }}
      {% endif %}
    {% endif %}
    <span class="divider" aria-hidden="true">&rsaquo;</span>
    <span class="breadcrumb--truncate">{{ product.title }}</span>

  {% elsif template.name == 'collection' and collection.handle %}

    <span class="divider" aria-hidden="true">&rsaquo;</span>

    {% if current_tags %}

      {% capture url %}/collections/{{ collection.handle }}{% endcapture %}
      {{ collection.title | link_to: url }}

      <span class="divider" aria-hidden="true">&rsaquo;</span>

      {% for tag in current_tags %}

        {% assign is_advanced_tag = false %}
        {% assign cat = tag | split: '_' | first %}
        {% unless cat == tag %}
          {% if cat_array contains cat %}
            {% assign is_advanced_tag = true %}
            <span>
              {{ tag | remove_first: cat | remove_first: '_' }}
            </span>
          {% endif %}
        {% endunless %}

        {% if is_advanced_tag == false %}
        <span>
          {{ tag }}
        </span>
        {% endif %}

        {% unless forloop.last %}
        <span>+</span>
        {% endunless %}

      {% endfor %}

    {% else %}
      <span>{{ collection.title }}</span>
    {% endif %}

  {% elsif template.name == 'blog' %}

    <span class="divider" aria-hidden="true">&rsaquo;</span>
    {% if current_tags %}
      {{ blog.title | link_to: blog.url }}
      <span class="divider" aria-hidden="true">&rsaquo;</span>
      <span>{{ current_tags | join: " + " }}</span>
    {% else %}
    <span>{{ blog.title }}</span>
    {% endif %}

  {% elsif template.name == 'article' %}

    <span class="divider" aria-hidden="true">&rsaquo;</span>
    {{ blog.title | link_to: blog.url }}
    <span class="divider" aria-hidden="true">&rsaquo;</span>
    <span>{{ article.title }}</span>

  {% elsif template.name == 'page' %}

    <span class="divider" aria-hidden="true">&rsaquo;</span>
   <span>{{ page.title }}</span>

  {% else %}

    <span class="divider" aria-hidden="true">&rsaquo;</span>
   <span>{{ page_title }}</span>

  {% endif %}
</nav>
{% endunless %}

 

0 Likes
Tourist
15 0 0

If you figured this out could you post the code or let me know?

0 Likes