Pregunta

Good day all. I have a Prestashop site, with different languages AND different countries, some of these countries uses the same language, but different currencies, or have small differences such as options available or colors for the product, but the main product is the same.

this has caused some warnings on the webmaster tools on google, mainly caused by duplicate title, or duplicate descriptions or similar.

the problem is that the Australian items is an english speaking item, but has different currencies and a different URL from the UK one.

searching on the web I have seen that a good practice is to insert the hreflang link with rel="alternate" so basically, I would like to obtain something like this in the head of the page:

<link rel="alternate" hreflang="en-us" href="http://www.example.com/en/page.html" />
<link rel="alternate" hreflang="en" href="http://www.example.com/en/page.html" />
<link rel="alternate" hreflang="en-au" href="http://www.example.com/au/page.html" />
<link rel="alternate" hreflang="de" href="http://www.example.com/de/seite.html" />

In a perfct world, all the combinations should be taken from the database, but I could live also with a "more" static solution as well. Does someone knows:

1) is this a solution for the problem i've noticed in webmaster tools?

2) which could be the best way to handle the warnings for duplicate content in this case (if answer 1 is "no")

3) Is there a clean way to handle the "en-us" (or any other combination) part?

4) Is there a clean way to handle the "/de/seite.html" (or else) part?

¿Fue útil?

Solución

I have developed a module to final handle it: http://www.matteobononi.it/prestashop_module_hreflang.php feel free to use it if you need.

The module works on Prestashop from 1.5 to 1.6, it adds the hreflang meta links in the head section of several page types.

Otros consejos

{PRESTA-1.6.x.x} Who have problem with hreflang can use this article https://rubendivall.com/anadir-canonical-y-hreflang-en-prestashop-16x-en/ or add this code in header.tpl in: < head>{code}< head/>

{if $page_name == 'category'}
<link rel="canonical" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}" />    
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getCategoryLink($smarty.get.id_category, null, $lang.id_lang,null,null )}" />{/foreach}{/if}
{if $start!=$stop}{if $p != 1 && $p_previous != 1}{assign var='p_previous' value=$p-1}
<link rel="prev" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}{$link->goPage($requestPage, $p_previous)}" />{/if}
{if $pages_nb > 1 AND $p != $pages_nb}{assign var='p_next' value=$p+1}
<link rel="next" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}{$link->goPage($requestPage, $p_next)}" />{/if}{/if}
{/if}
{if $page_name == 'product'}    
<link rel="canonical" href="{$link->getProductLink($smarty.get.id_product, null, null, null, $id_lang, null, 0, false)}" />    
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getProductLink($smarty.get.id_product, null, null, null, $lang.id_lang, null, 0, false)}" />{/foreach}{/if} 
{/if}
{if $page_name == 'cms' && $smarty.get.id_cms > 0}
<link rel="canonical" href="{$link->getCMSLink($smarty.get.id_cms, null, false, $id_lang)}" />
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getCMSLink($smarty.get.id_cms, null, false, $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'manufacturer' && $smarty.get.id_manufacturer > 0}
<link rel="canonical" href="{$link->getManufacturerLink($smarty.get.id_manufacturer, null, $id_lang)}" />    
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getManufacturerLink($smarty.get.id_manufacturer, null, $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'manufacturer' && !isset($smarty.get.id_manufacturer)}
<link rel="canonical" href="{$link->getPageLink('manufacturer', 'true', $id_lang)}" />    
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getPageLink('manufacturer', 'true', $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'index'}
<link rel="canonical" href="{$link->getPageLink('index', 'true', $id_lang)}" />    
{if $languages|@count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getPageLink('index', 'true', $lang.id_lang)}" />{/foreach}{/if}
{/if}

I wrote this solution. Insert it between <head></head> and change the languages /en/ && /es/ etc.

    {if mb_strstr($smarty.server.REQUEST_URI, '/en/')}
        <link rel="alternate" hreflang="es" href=http://{$smarty.server.SERVER_NAME}/es{substr($smarty.server.REQUEST_URI, 3)}  />
        <link rel="alternate" hreflang="de" href=http://{$smarty.server.SERVER_NAME}/de{substr($smarty.server.REQUEST_URI, 3)} />           
    {elseif mb_strstr($smarty.server.REQUEST_URI, '/es/')}
        <link rel="alternate" hreflang="en" href=http://{$smarty.server.SERVER_NAME}/en{substr($smarty.server.REQUEST_URI, 3)} />
        <link rel="alternate" hreflang="de" href=http://{$smarty.server.SERVER_NAME}/de{substr($smarty.server.REQUEST_URI, 3)} />
    {elseif mb_strstr($smarty.server.REQUEST_URI, '/de/')}
        <link rel="alternate" hreflang="es" href=http://{$smarty.server.SERVER_NAME}/es{substr($smarty.server.REQUEST_URI, 3)} />
        <link rel="alternate" hreflang="en" href=http://{$smarty.server.SERVER_NAME}/en{substr($smarty.server.REQUEST_URI, 3)} />
    {/if}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top