Magento SEO: Canonical Links
One 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.
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.
Subscribe to "The Integration Engineer" by Email
Find out about the tools and services available at The Integration Engineer's Consulting site.


August 29th, 2011 at 11:56 pm
How can I put a rel=canonical to every single product? I mean product A doesn’t have canonical but product B has canonical to product A and product C has also canonical to product A?
September 2nd, 2011 at 2:25 pm
Not sure that I have explained this.
The problem that we are solving is that without using the relational canonical links, search engines like Google see http://yoursite.com/productA and http://yoursite.com/someCatagory/productA as two unique URL location’s with identical content. This makes Google spread the relevance and authority of the content across both URL indexes.
Because we want only one page of unique content to be indexed to maximize our relevance and page rank, we tell Google to ignore the fact that there are two or more URL locations, and to put it all under the URL we are designating.
Making two or more products use the same canonical link would only work if the products were identical. Giving the same canonical link to different pages that are not identical would be bad for our page rank and would probably cause the Google bot to ignore our page altogether.
I hope this answers your question.