Products SEO : HREFLANG Tags for Multilanguage Products Site

If you have a multilanguage catalog site that uses the Products Module, here is a way to configure your CANONICAL and HREFLANG links correctly to avoid being penalized by Google Panda.

I ran into this problem when configuring a Multilanguage website using Multilanguage CMS and the Products Modules.  How do I correctly configure my canonical links when I am serving the same product detail page in several languages?

According to SEO Experts and Google Webmaster Tools, the proper configuration is to have a separate page for each language that contains hreflang links to the other language pages with translated content, and a canonical link the primary language page for the content.  For example:

<!-- the canonical link for this product is the english page -->
<link rel="canonical" href="http://yoursite.com/en/products/cool-widget.htm">

<!-- this tells google the russian version of the same page -->
<link rel="alternate" hreflang="ru" href="http://yoursite.com/ru/produkty/cool-widget.htm">

<!-- this tells google the spanish version of the same page -->
<link rel="alternate" hreflang="es" href="http://yoursite.com/es/productos/cool-widget.htm">

So the question is how to configure the Products module with CMS Made Simple to generate this kind of page structure, and secondly, how to generate the correct link tags for the head.

Here is how I solved this problem.  First, following the steps in this MLE CMS tutorial, I set up the Multi-Language site to have a products page under each top level language page.  Since I was working with four languages, that means I had four products pages, each with a different page alias:

  • English = products
  • Czech = produkty
  • Russian = produkty2
  • Spanish = productos

First I need to go to the Products Manager "Preferences" tab and set the default detail page and the default hierarchy page to "none". This will make sure that the pretty urls will follow different paths depending on the language.

Next, in the "Product Detail" template for the products module, I added the following code near the top:

{* Set Canonical And Language Links *}
{capture assign='href_lang'}
	<link rel="canonical" hreflang="en" href={module_action_link module='Products' action='details' productid=$entry->id detailpage='products' page='products' urlonly=1}> 
	<link rel="alternate" hreflang="cz" href={module_action_link module='Products' action='details' productid=$entry->id detailpage='produkty-2' page='produkty-2' urlonly=1}>
	<link rel="alternate" hreflang="ru" href={module_action_link module='Products' action='details' productid=$entry->id detailpage='produkty' page='produkty' urlonly=1}>
	<link rel="alternate" hreflang="es" href={module_action_link module='Products' action='details' productid=$entry->id detailpage='Productos' page='Productos' urlonly=1}>
{/capture}

This uses the {module_action_link} plugin from the Module "CGSimpleSmarty" to create a url link to the pages in various languages. (CGSimpleSmarty is a required module for Products, so if you have installed Products, you should already have this module installed.)

Now I put this in the head section of my template:

{if isset($href_lang)}
   {$href_lang}
{/if}

You can something similar for your "Product Hierarchy" template. In the hierarchy template the data for the current hierarchy level is contained in the object $hierarchy_item. The current hierarchy name is $hierarchy_item.name.

So I put the following block of code in the top of the Product Hierarchy Template:

{if isset($hierarchy_item) && $hierarchy_item.name != ''}
{capture assign='href_lang'}
	<link rel="canonical" hreflang="en" href={module_action_link module='Products' action='hierarchy' hierarchy=$hierarchy_item.name detailpage='products' page='products' urlonly=1}> 
	<link rel="alternate" hreflang="cz" href={module_action_link module='Products' action='hierarchy' hierarchy=$hierarchy_item.name detailpage='produkty-2' page='produkty-2' urlonly=1}>
	<link rel="alternate" hreflang="ru" href={module_action_link module='Products' action='hierarchy' hierarchy=$hierarchy_item.name detailpage='produkty' page='produkty' urlonly=1}>
	<link rel="alternate" hreflang="es" href={module_action_link module='Products' action='hierarchy' hierarchy=$hierarchy_item.name detailpage='Productos' page='Productos' urlonly=1}>
{/capture}
{/if}

This works pretty well for me. I hope you will find it useful as well!

Arvixe Hosting

Comments