SEO Tips for Prestashop and other Websites

These tips were written in English, please use the English version for the correct code examples.


Pick a default URL

Search engines see www.your_site.com and your_site.com as two different URLs.

If they find links to both versions, they think it is duplicate data and penalize your ranking.

You should pick a default URL (with www or without), and make sure one redirects to the other.

You can do this by adding one of the following to your /.htaccess file.


Redirect your_site.com to www.yoursite.com:

RewriteEngine on (ONLY if it's not already there)

RewriteCond %{HTTP_HOST} ^your_site.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]

Redirect www.your_site.com to your_site.com:

RewriteEngine on (ONLY if it's not already there)

RewriteCond %{HTTP_HOST} ^www.your_site.com$ [NC]
RewriteRule ^(.*)$ http://your_site.com/$1 [R=301,L]


Prevent URL Duplication

 

Prestashop doesn't handle duplicate URLs very well, even after you turn "Friendly URLs" on, you can still access pages with the old URL structure.

In addition, any time you change the name of a product, or move it to a different category, the old URL is still working.

If Search Engines see that, they think you have duplicate data and they give you a penalty for it.

We have created a Duplicate URL Redirect Module that uses a Search Engine friendly 301 redirect to point all of the old URLs to the current default ones.

It redirects old non-Friendly URLs (I.E www.yoursite.com/category.php?id_category=2 to www.yoursite.com/2-current-category-name).

It redirects old Friendly URL names (I.E www.yoursite.com/2-old-category-name to www.yoursite.com/2-current-category-name).

It redirects the URL of the default language in Prestashop 1.2 (I.E www.yoursite.com/lang-en to www.yoursite.com).

It redirects index.php to the shop's URL (I.E www.yoursite.com/index.php to www.yoursite.com).


Prevent Meta Tag Duplication

If you are using Prestashop 1.5.4 or older, these changes are no longer needed

 

Read and follow the Duplicate URL Fix instructions (Prestashop older than 1.4.3 ONLY)

The following example functions were written for PS 1.3, while the location of files may have changes in later versions, the logic of the fix remains the same, adding the page number to the meta tags

The Pagination creates new URLs for pages with different content in them, but using the same Page Title and description.

URL/11-category-name
URL/11-category-name?p=1
URL/11-category-name?p=2

Search Engines see this as duplicate meta tag information it's not nearly as bad as content or URL duplication, but should be avoided when possible.

You can change that by adding the page number into the Meta Tag information, which will make each page unique.

 

Open /classes/Tools.php and replace the function completeMetaTags (around line #500) with the function below.

 

static public function completeMetaTags($metaTags$defaultValue)
    
{
        
global $cookie;
        
$no_duplication "";
        if (
self::getValue('p'))
            
$no_duplication .= ($no_duplication != ""?" #":"#").self::getValue('p');
        if (
$no_duplication != "")
            
$no_duplication " (".$no_duplication.")";
        if (
$metaTags['meta_title'== NULL)
            
$metaTags['meta_title'Configuration::get('PS_SHOP_NAME').' - '.$defaultValue;
        
$metaTags['meta_title'.= $no_duplication;
        if (
$metaTags['meta_description'== NULL)
            
$metaTags['meta_description'= (Configuration::get('PS_META_DESCRIPTION'intval($cookie->id_lang)) ? Configuration::get('PS_META_DESCRIPTION'intval($cookie->id_lang)) : '');
        
$metaTags['meta_description'.= $no_duplication;
        if (
$metaTags['meta_keywords'== NULL)
            
$metaTags['meta_keywords'Configuration::get('PS_META_KEYWORDS'intval($cookie->id_lang)) ? Configuration::get('PS_META_KEYWORDS'intval($cookie->id_lang)) : '';
        return 
$metaTags;
    
}

Open /classes/Tools.php and replace the function getHomeMetaTags (around line #490) with the function below.

 

static public function getHomeMetaTags($id_lang)
    
{
        
global $cookie$page_name;

        
/* Metas-tags */
        
$metas Meta::getMetaByPage($page_name$id_lang);
        
$ret['meta_title'= (isset($metas['title']) AND $metas['title']) ? Configuration::get('PS_SHOP_NAME').' - '.$metas['title'Configuration::get('PS_SHOP_NAME');
        
$ret['meta_description'= (isset($metas['description']) AND $metas['description']) ? $metas['description''';
        
$ret['meta_keywords'= (isset($metas['keywords']) AND $metas['keywords']) ? $metas['keywords':  '';
        
$no_duplication "";
        if (
self::getValue('p'))
            
$no_duplication .= ($no_duplication != ""?" #":"#").self::getValue('p');
        if (
$no_duplication != "")
        
{
            $ret[
'meta_title'.= " (".$no_duplication.")";
            
$ret['meta_description'.= " (".$no_duplication.")";
        
}
           
return $ret;
    
}


Prevent Meta Tag Duplication for Multiple Languages

Prestashop V1.2 is very SEO friendly for multiple languages.

Every language has it's own URL for each page, which lets search engines index all of them.

However, the page title remains the same for all languages (unless manually changed), which search engines penalize.

You can fix that by automatically adding the language name to each page title.

Replace the current <title>...</title> tag in /themes/prestashop/header.tpl line #4 with the one below:

<title>{$meta_title|escape:'htmlall':'UTF-8'} {foreach from=$languages item=language}{if $language.iso_code == $lang_iso} ({$language.name}){/if}{/foreach} </title>

Replace the current <meta name="description"> tag in /themes/prestashop/header.tpl line #6 with the one below:

<meta name="description" content="{$meta_description|escape:htmlall:'UTF-8'}{foreach from=$languages item=language}{if $language.iso_code == $lang_iso} ({$language.name}){/if}{/foreach}" />