Jump to content
Noeliapmm

Evitar duplicidades - ¿Es válido este código?

Recommended Posts

Hola a todos.

 

Por motivos varios, he llegado a utilizar unas líneas de código, que según sus autores, solucionan el problema de duplicidad de contenidos para Google en nuestro querido Prestashop.

 

Quería dejaros aquí las dos opciones, en primer lugar, para ver si algún experto puede decirnos si realmente hacen los que prometen. 

 

Y en segundo lugar, pues que si funcionan, los tenéis aquí disponibles. 

 

En ambos casos, debéis editar el archivo HEADER.TPL de vuestra plantilla (themes/default-bootstrap para el tema por defecto), e introducir el código dentro de la etiqueta <head>

 

Caso / Ejemplo 1

 

<!-- canonical -->
{if isset($smarty.get.p) && !empty($smarty.get.p)}
{assign var="pagenumber" value={l s=' - Page %1$d' sprintf=$smarty.get.p} }
{assign var="pagination" value="?p={$smarty.get.p}" }
{else}
{assign var="pagenumber" value="" }
{assign var="pagination" value="" }
{/if}
 
{assign 'pages_array' ['best-sales', 'new-products', 'adresses', '404', 'address', 'authentication', 'my-account', 'contact-form', 'discount', 'guest-tracking', 'index', 'history', 'manufacturer', 'order-opc', 'order-follow' ,'order-carrier' ,'order-payment', 'order-detail', 'order-slip', 'order-return', 'order-confirmation', 'order-address', 'password', 'search', 'prices-drop', 'sitemap', 'store-infos', 'stores', 'supplier-list', 'suppliers']}
 
{assign 'noindex_pages_array' ['404', 'address', 'my-account', 'guest-tracking', 'order-opc', 'order-follow' ,'order-carrier' ,'order-payment', 'order-detail', 'order-slip', 'order-confirmation', 'order-address', 'cart', 'search', 'supplier-list', 'supplier', 'suppliers']}
 
{if isset($smarty.server.REQUEST_URI)}
 
{assign 'noindex_vars' ['noredirect','orderway','orderby','content_only']}
 
{foreach from=$noindex_vars item=v}
{if stristr($smarty.server.REQUEST_URI,$v) }
{assign var=nobots value=true}
{break}
{/if}
{/foreach}
 
{/if}
 
{if $page_name == 'product' && isset($product->id)}
<link rel="canonical" href="{$link->getProductLink($product->id)}" />
{elseif $page_name == 'manufacturer' && isset($manufacturer->id)}
<link rel="canonical" href="{$link->getManufacturerLink($manufacturer->id)}{$pagination}" />
{elseif $page_name == 'supplier' && isset($supplier->id)}
<link rel="canonical" href="{$link->getSupplierLink($supplier->id)}{$pagination}" />
{elseif $page_name == 'category' && isset($category->id)}
<link rel="canonical" href="{$link->getCategoryLink($category->id)}{$pagination}" />
{elseif in_array($page_name,$pages_array)}
<link rel="canonical" href="{$link->getPageLink($page_name)}" />
{elseif $page_name == 'cms' && isset($cms->id)}
<link rel="canonical" href="{$link->getCmsLink($cms->id)}" />
{else}
 
{assign var=amn value=explode("-",$page_name)}
{if strpos($page_name,"module-") !== false && count($amn) == 3}
<link rel="canonical" href="{$link->getModuleLink($amn.1,$amn.2)}{$pagination}" />
{else}
<link rel="canonical" href="{$base_dir|replace:'.fr/':'.fr'|replace:'http':'https'}{$request_uri|regex_replace:'/\?(.*)/':''|replace:'index.php':''}{$pagination}" />
{assign var=nobots value=true}
{/if}
{/if}
 
{if in_array($page_name,$noindex_pages_array)}
{assign var=nobots value=true}
{/if}
<!-- canonical -->

 

 

 

Caso / Ejemplo 2

 

<!-- canonical -->
{if $page_name == 'index' or $page_name == 'search'}
<link rel="canonical" href="{$base_dir}" />
{elseif $page_name == 'category' or $page_name == 'best-sales' or $page_name == 'cart' 
or $page_name == 'discount' or $page_name == 'manufacturer' or $page_name == 'new-products'
or $page_name == 'prices-drop'}
<link rel="canonical" href="{$base_dir}
{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''}" />
{else}
<link rel="canonical" href="{$base_dir}{$request_uri|substr:1}" />
{/if}
<!-- /canonical -->

 

 

Pues eso. A ver si alguien nos ilumina.....

 

Muchas gracias

 

Saludos

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More