How to Add SEO-Friendly Breadcrumbs to Shopify Product Pages

Published on Jun 7, 2024

By Michael Chen

#Shopify#E-commerce#Web Development
Laptop z otwartym panelem sklepu internetowego Shoper

In the world of e-commerce, navigation is key. One of the most effective ways to improve your store’s user experience is by implementing breadcrumbs. This article will guide you through the process of adding breadcrumbs to your Shopify product pages, enhancing navigation, and potentially boosting your SEO.

Understanding Breadcrumbs in Shopify

Breadcrumbs are a navigational aid that shows users their current location within a website’s hierarchy. They’re not just useful for visitors; they can also improve your site’s SEO by providing clear pathways for search engines to crawl.

Why Breadcrumbs Matter

Breadcrumbs offer several benefits:

  1. Improved navigation: Users can easily understand and navigate your site structure.
  2. Reduced bounce rates: By providing clear paths, users are less likely to leave your site in confusion.
  3. Enhanced SEO: Search engines can better understand your site’s structure, potentially improving your rankings.

Types of Breadcrumbs

There are three main types of breadcrumbs:

  1. Hierarchy-based (location-based)
  2. Attribute-based
  3. History-based (path-based)

For Shopify product pages, we’ll focus on hierarchy-based breadcrumbs, which show the site’s structure.

Adding Breadcrumbs to Your Shopify Product Pages

Now, let’s dive into the practical steps of adding breadcrumbs to your Shopify store.

Step 1: Accessing Your Theme Files

To begin, you’ll need to access your theme files:

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

Step 2: Locating the Product Template

Find the product-template.liquid file in your theme files. This is where we’ll add our breadcrumb code.

Step 3: Adding the Breadcrumb Code

Here’s the code you’ll need to add to your product-template.liquid file:

<nav aria-label="Home" class="breadcrumb">
  <a class="Breadcrumbs" href="{{ routes.root_url }}">Home </a> /
  <a class="Breadcrumbs" href="/collections/{{ product.type | handleize}}"> {{ product.type }} </a> /
  <span class="breadcrumb__link" aria-current="page" style="font-weight:bold;"> {{ product.title}}</span>
</nav>

Add this code near the top of your product-template.liquid file, typically just after the opening “ tag.

Step 4: Styling Your Breadcrumbs

To ensure your breadcrumbs look good and fit with your theme, you’ll want to add some CSS. Add the following to your theme.css.liquid file:

.breadcrumb {
  margin-bottom: 20px;
  margin-left: 45px;
}

Feel free to adjust these values to fit your specific layout needs.

Troubleshooting Common Issues

While adding breadcrumbs is generally straightforward, you might encounter some issues. Here are some common problems and their solutions.

404 Errors on Collection Links

If clicking on the collection link in your breadcrumbs leads to a 404 error, it’s likely because you don’t have a collection that matches your product type. To fix this:

  1. Create a new collection in your Shopify admin
  2. Name it exactly the same as your product type
  3. Add all relevant products to this collection

Breadcrumbs Not Displaying Correctly

If your breadcrumbs aren’t showing up or look odd, double-check your code placement. Ensure it’s in the correct location within your product-template.liquid file.

Styling Issues

If your breadcrumbs don’t look quite right, you may need to adjust your CSS. Play around with margins, padding, and font styles until you’re happy with the result.

Advanced Breadcrumb Customization

Once you’ve got the basics down, you might want to customize your breadcrumbs further.

Using Collections Instead of Product Types

If you prefer to use collections instead of product types in your breadcrumbs, you’ll need to modify the code slightly. Here’s an example:

<nav aria-label="Home" class="breadcrumb">
  <a class="Breadcrumbs" href="{{ routes.root_url }}">Home </a> /
  <a class="Breadcrumbs" href="{{ collection.url }}">{{ collection.title }}</a> /
  <span class="breadcrumb__link" aria-current="page" style="font-weight:bold;">{{ product.title }}</span>
</nav>

This code assumes that your product is associated with a single collection. If a product belongs to multiple collections, Shopify will use the first one it finds.

Adding Schema Markup

To further boost your SEO, consider adding schema markup to your breadcrumbs. This helps search engines understand your site structure better. Here’s an example of how you might implement this:

<nav aria-label="Home" class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
  <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a class="Breadcrumbs" href="{{ routes.root_url }}" itemprop="item"><span itemprop="name">Home</span></a>
    <meta itemprop="position" content="1" />
  </span> /
  <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <a class="Breadcrumbs" href="/collections/{{ product.type | handleize}}" itemprop="item"><span itemprop="name">{{ product.type }}</span></a>
    <meta itemprop="position" content="2" />
  </span> /
  <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
    <span class="breadcrumb__link" aria-current="page" style="font-weight:bold;" itemprop="name">{{ product.title }}</span>
    <meta itemprop="position" content="3" />
  </span>
</nav>

This code adds schema.org markup to your breadcrumbs, which can help search engines better understand your site structure.

By following this guide, you should now have functional, SEO-friendly breadcrumbs on your Shopify product pages. Remember, the key to successful e-commerce is constant improvement, so don’t be afraid to tweak and refine your breadcrumbs as you learn more about your customers’ needs and behaviors.

Take Our Quick Quiz:

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