Magento EcommerceOne of the things that can be an SEO concern for Magento deployments is the proliferation of URLs that don't have unique content. ÂIf you haven't realized this, the product URL, and the Category/Product URL are the same content, but the URL is different. ÂWhich one should the search engine index? ÂBoth? ÂIf it does, you lose some of the "Link Juice" and your page rank can suffer.

Google addressed this concern not specifically for Magento sites in a June 17th, 2011 posting. ÂIn this article Google explains how they support canonical relational links in the header. ÂNow you just need to add these to the header of your Magento pages so that Google and other search engines can realize that the category item and the product item are the same page. Â And here is a quick way to do just that.

First, you will need to be familiar with your theme, and navigate to the app/design/frontend/[theme name]/main/page/html/page/

Here you will find a file called head.phtml ÂThis is the file you will need to edit.

Adding canonical links for your products and categories:

In the head.phtml file find the group of code that has <link> content. ÂIn mine this was right after the <meta> content.

<?php if(Mage::registry('product')): ?>

<link rel="canonical" href="<?php echo Mage::registry('product')->getProductUrl(); ?>" />

<?php elseif(Mage::registry('current_category')): ?>

<link rel="canonical" href="<?php echo Mage::registry('current_category')->getUrl(); ?>" />

<?php endif; ?>

What is this doing?

  • First there is a call to the Magento Registry to find out where the visitor is looking. ÂThe PHP if condition is looking for if this is a product, or category.
  • Inside the if condition we create the html <link/>
  • Inside the link tag, we are going to call the Magento Registry and get the product or category URL to use as the HREF target.
  • This does one of three things; create a link tag with the category URL, create link with product URL, or not create anything.
Done

After you save the file you can see that it works by going to a category or product page. ÂYou will have to view the page source and look in the <header> section to find the new link. Â(you might want to refresh the cache.)

And it is just that simple.

You now have a Magento Store that will concentrate its "Link Juice" on fewer URLs and reduce aÂredundancyÂof indexing Âin the search engines.