Add a “no follow” tag to layered navigation links

If you have a lot of categories and/or subcategories, it doesn’t make a lot of sense to have the search engine robots index and follow all your layered navigation links. While you might think it would be great to have so many extra pages indexed, you’re really only creating hundreds or thousands of duplicate content pages that could ultimately lessen your SEO rankings in the long run.

There’s an easy way to quickly add a rel=”no follow” tag to all your layered navigation links:

(The original page depends on how you’ve structured your site using DEFAULT, BASE or YOURTHEME – you don’t want to modify the original core Magento pages)

COPY: app/design/frontend/default/DEFAULT OR BASE/template/catalog/layer/filter.phtml

TO: app/design/frontend/default/YOURTHEME/template/catalog/layer/filter.phtml

around line 41 add the rel=”nofollow” tag between the “<a  ‘ and ‘href’

<?php foreach ($this->getItems() as $_item): ?>
<?php if ($_item->getCount() > 0): ?>
<a rel="nofollow" href="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?></a>
<?php else: echo $_item->getLabel() ?>
<?php endif; ?>
<?php if ($this->shouldDisplayProductCount()): ?>
(<?php echo $_item->getCount() ?>)
<?php endif; ?>
<?php endforeach ?>

Install the change, clear your cache and you’ll notice all your layered navigation links now have rel=”no follow” which will hopefully reduce your duplicate content issues and also decrease the processing resources required on your server to handle all those page requests.


Leave a Reply