Add breadcrumbs structured data (rich snippets)

I tried various methods to add structured data to the breadcrumbs and found the method below the easiest to implement and most reliable. Inserting the crumbinfo as part of the label link caused display issues, so the safest implementation was to simply create a separate span section with the breadcrumb data.

Open: app/design/frontend/default/YOURTHEME/template/page/html/breadcrumbs.phtml

Note: if your theme doesn’t have this template, backtrack into the app/design/frontend/core/… or app/design/frontend/default/…  directories and copy from there into your template hierarchy.

Open the template and insert the span section below the <a href … so that the codes looks like this ..

<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>" ><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
<span itemscope itemtype="">
<meta itemprop="url" content="<?php echo $this->htmlEscape($_crumbInfo['link']) ?>" />
<meta itemprop="title" content="<?php echo $this->htmlEscape($_crumbInfo['label']) ?>" />
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

After you’ve uploaded, go to Google Webmaster Tools and use the structured data testing tool to view your results.

NOTE:  The structured data only picks up what’s displayed on the page. If all your breadcrumbs aren’t on the page then you’ll need to “force” the page to display all the breadcrumbs.  Here’s a post to check out – .Display the full breadcrumb path on product page




Leave a Reply