WooCommerce

BreadcrumbList JSON-LD for WooCommerce, Without the Guesswork

BreadcrumbList JSON-LD for WooCommerce catalogs is structured data that mirrors the category path a shopper sees, so search engines can show the same trail in results. I build it from the same term and product data that renders the visible breadcrumb, then verify each ListItem position, name and item URL against the rendered page.

By Saif Al Jahanwebdev-saif.com

The exact shape Google expects from BreadcrumbList

BreadcrumbList is a schema.org type made of an itemListElement array. Each entry is a ListItem with a 1-based integer position, a name, and an item URL. The first item is normally Home and the last is the current product or category. Google treats this as a correctness check, not a ranking boost: if the positions skip, the names are empty, or the URLs do not resolve to real pages, the enhancement is ignored. I emit the block as JSON-LD in the head from a single PHP function, so it is present in the initial HTML response rather than injected later by a tag manager. That matters because answer engines and crawlers may read only the first response body.

  • Use "@type": "BreadcrumbList" with a complete itemListElement array
  • Number positions as integers starting at 1, never 0
  • Set name to the visible label, not a rewritten keyword variant
  • Set item to an absolute, canonical URL with no tracking parameters
  • Emit JSON-LD server-side so it exists in the raw HTML response

Mapping a WooCommerce product_cat hierarchy

A product can sit in several categories, so the first job is choosing one canonical trail. I read the term IDs with wp_get_post_terms( $product_id, "product_cat" ), then take the deepest term and walk its ancestors with get_ancestors( $term_id, "product_cat" ). Reversing that array gives parent to child order, which becomes the breadcrumb path. When a product belongs to multiple branches, I pick the same branch the theme renders in its visible breadcrumb and use it everywhere. Guessing a different branch in the schema than the one on screen is the most common cause of a mismatch. I also skip the uncategorized default term, which is noise rather than navigation.

  • wp_get_post_terms( $id, "product_cat" ) for assigned terms
  • get_ancestors() to rebuild the parent-to-child chain
  • One chosen branch per product, reused in markup and template
  • Exclude the default Uncategorized term from the trail
  • Use get_term_link() for each absolute item URL

Variable products: point at the parent, not the variation

This is where most WooCommerce breadcrumb schema goes wrong. A variation such as ?attribute_pa_color=red is the same product, not a new catalog level. The schema item URL and the rel="canonical" should both point to the clean parent permalink from get_permalink( $parent_id ), not to a query-string variation URL. The visible breadcrumb should agree. If your theme appends the selected attribute to the current URL after a variation switch, keep that out of the structured data. The same rule applies to paginated category pages and filter parameters: page/2 and ?filter_size=xl are not breadcrumb levels and should never appear as ListItem entries.

Matching the JSON-LD to the visible breadcrumb

Google asks that the marked-up trail reflect what a visitor actually sees, so I generate both from one function and render twice: once into the woocommerce_breadcrumb output and once into JSON-LD. The visual trail usually hooks woocommerce_before_main_content with woocommerce_breadcrumb(), and its separator, home label and wrapper can be changed through the woocommerce_breadcrumb_defaults filter. I keep the default text labels simple and never rename a level differently in the schema. Term names come from the same WP_Term objects in both paths, which removes drift when a category is renamed in the dashboard. Consistency here is more valuable than a clever label.

  • Build the trail array once, then render HTML and JSON-LD from it
  • Hook woocommerce_before_main_content for the visible trail
  • Use woocommerce_breadcrumb_defaults only for separator and wrappers
  • Pull labels from the same WP_Term objects in both outputs
  • Keep Home as position 1 in both the page and the markup

Drift I see in real catalogs

The frequent failure is not missing schema, but duplicated or contradictory schema. A general SEO plugin can output its own breadcrumbs while the theme renders another set, and the result is two BreadcrumbList blocks that disagree. I disable one source and keep the one tied to the product data. Other problems include relative URLs, HTML entities left in term names, position numbers that restart on a category archive, and a last item that links back to itself. Each of these is invisible on the page but breaks validation. I also avoid marking up breadcrumbs on search result pages, cart and checkout, where a category trail does not exist and adding one would be fabrication.

Verification before launch

In my work at webdev-saif.com, validation is quick and part of the launch checklist. I take a product with a three-level category path and a variable product with two variations, then paste each rendered URL into the Rich Results Test and confirm a BreadcrumbList enhancement with no errors. I compare the reported items line by line with the on-page trail. After deployment I watch Search Console under Enhancements for Breadcrumbs, which reports invalid items across the catalog rather than one page at a time. Fixing a shared template then clears the whole group. This is a practical target I use in my builds, not a promise of a specific ranking change.

  • Rich Results Test on a deep category product and a variable product
  • Compare every ListItem name and URL with the rendered trail
  • Watch Search Console Enhancements for Breadcrumbs errors
  • Fix the shared template, not individual product pages
  • Re-test after any term rename or permalink structure change

Frequently asked questions

What is BreadcrumbList JSON-LD in a WooCommerce store?

It is a block of schema.org markup describing the navigation path from the home page to the current product or category. It uses an itemListElement array of ListItem objects with position, name and item URL. Search engines use it to display a breadcrumb trail in results and to confirm that your page structure is clear.

Should the final breadcrumb item have a URL?

The last item can omit item because it represents the current page, but including a self-referencing canonical URL is also accepted. I keep the same approach across the catalog. What matters is that the URL, when present, resolves cleanly and matches the page being viewed, without tracking parameters or variation query strings.

How should variable products be handled in breadcrumb schema?

Treat a variable product as one item and point to the clean parent permalink. A variation URL with attribute query strings is not a separate catalog level, so it should not add a breadcrumb or change the item URL. The canonical tag and the visible breadcrumb should point to the same parent URL.

Does the markup have to match the visible breadcrumbs?

Yes. Google expects the structured data to reflect the trail a visitor sees. If the page shows Home > Shoes > Running and the JSON-LD shows a different category branch, the enhancement can be flagged or ignored. Generating the HTML trail and the JSON-LD from one array of terms is the simplest way to keep them aligned.

Can an SEO plugin generate this for me?

It can, but general plugins often add their own block while the theme adds another. I prefer one controlled function in the theme or a small custom plugin that reads the same product_cat terms the page renders. That avoids duplicate BreadcrumbList markup and gives me control over canonical URLs for variable products.

How do I check that my breadcrumb schema is valid?

Paste a rendered product URL into Google Rich Results Test and confirm that a BreadcrumbList enhancement appears with no errors. Compare each listed name and URL with the visible trail. Then monitor Search Console under Enhancements for Breadcrumbs, which groups invalid items across the catalog so you can fix the shared template once.

Written by Saif Al Jahan, webdev-saif.com · Mymensingh, Bangladesh. Last updated .