Breadcrumbs needed Home > Pages > Collection > Product

Topic summary

A Shopify store owner is attempting to implement dynamic breadcrumb navigation that tracks the user’s actual navigation path rather than just reflecting the current URL structure.

Desired behavior:

  • Home → Page should display: Home > Page
  • Home → Page → Collection should display: Home > Page > Collection
  • Home → Page → Collection → Product should display: Home > Page > Collection > Product
  • Breadcrumbs should update when users navigate backward

Current problem:
The existing Liquid-based implementation from Shopify only shows the current page context:

  • After navigating from Page to Collection, it displays Home > Collection instead of the expected Home > Pages > Collection
  • The breadcrumb trail doesn’t preserve the navigation history

Status: The issue remains unresolved, with the user seeking a quick solution for implementing path-tracking breadcrumbs that maintain the full navigation sequence rather than template-based breadcrumbs.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

Hello Everyone!

I’m trying to build a dynamic breadcrumb navigation system in my Shopify store, but I can’t get it to work properly across all page levels.

Here’s what I want to achieve:

  • When a user navigates from Home → Page, the breadcrumb should show:
    Home > Page

  • When they go from that Page → Collection, it should show:
    Home > Page > Collection

  • When they go further into a Product, it should show:
    Home > Page > Collection > Product

  • And if the user goes back, it should update accordingly (for example, Product → Collection → Page).

Basically, I want breadcrumbs that follow the user’s navigation path dynamically, not just based on the current URL template.

I tried a Liquid-based setup From shopify but that gives me:

Home > pages

after the redirection from Page to Collection page it gives me

Home > Collection

it should gives me Home > Pages > Collection / currect page .

Have someone solution for this i need quick solution for this Kind of tracking Breadcrumbs.

1 Like

Hi @vortifytech1

Step-by-Step Solution

1. Add a Breadcrumb Container in Your Theme

In your desired layout (like sections/breadcrumb.liquid or directly in theme.liquid), add:

<nav class="dynamic-breadcrumbs" aria-label="Breadcrumb"></nav>

2. Add This JavaScript (can go in theme.liquid before </body>)

<script>
document.addEventListener('DOMContentLoaded', function() {
  const breadcrumbContainer = document.querySelector('.dynamic-breadcrumbs');
  if (!breadcrumbContainer) return;

  // Get current page info
  const pageTitle = document.title.replace('|', '').trim();
  const pageUrl = window.location.pathname;

  // Get stored breadcrumb trail
  let trail = JSON.parse(localStorage.getItem('breadcrumbTrail')) || [];

  // Check if current page is already in trail
  const existingIndex = trail.findIndex(item => item.url === pageUrl);
  if (existingIndex !== -1) {
    trail = trail.slice(0, existingIndex + 1);
  } else {
    trail.push({ title: pageTitle, url: pageUrl });
  }

  // Limit breadcrumb length (optional)
  if (trail.length > 5) trail = trail.slice(trail.length - 5);

  // Save updated trail
  localStorage.setItem('breadcrumbTrail', JSON.stringify(trail));

  // Render breadcrumbs
  let html = `<a href="/">Home</a>`;
  trail.forEach((item, index) => {
    html += ` <span>›</span> `;
    if (index === trail.length - 1) {
      html += `<span>${item.title}</span>`;
    } else {
      html += `<a href="${item.url}">${item.title}</a>`;
    }
  });
  breadcrumbContainer.innerHTML = html;
});
</script>
  1. Style It (optional)
.dynamic-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
}
.dynamic-breadcrumbs a {
  color: var(--color-link, #000);
  text-decoration: none;
}
.dynamic-breadcrumbs span {
  color: #666;
}
1 Like

This not works. It gives me another page title.

Hi @vortifytech1,

That kind of dynamic breadcrumb (following the actual user navigation path instead of just URL hierarchy) isn’t natively supported in Shopify Liquid — it can only build static breadcrumbs based on the current template (e.g., collection → product).

If you want a smart, dynamic breadcrumb that updates as users move between pages, you can try our Tapita AI Sections & Blocks app. It’s a free Breadcrumb Section that automatically handles breadcrumbs across pages, and you can customize its design without touching any code.

image

View the breadcrumbs demo here.

Hope this helps you save time building it manually!

Sophia - The Tapita team