PrestaShop Forums: [How-To] Prevent Meta Tag Duplication - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


[How-To] Prevent Meta Tag Duplication


[How-To] Prevent Meta Tag Duplication

#1 tomerg3

    PrestaShop Superstar

  • 10 Feb 2009
  • US Moderators
  • 5158 posts

Posted 25 April 2010 - 07:16 PM

The "Sort Order" and "Pagination" create 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?orderby=name&orderway=asc
URL/11-category-name?orderby=name&orderway=desc
URL/11-category-name?orderby=price&orderway=asc
URL/11-category-name?orderby=price&orderway=desc
URL/11-category-name?orderby=quantity&orderway=desc

Search Engines see this as duplicate meta tag information, and may penalize you for it.

You can change that by adding the sort order and 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('orderby'))
$no_duplication .= self::getValue('orderby')." ".self::getValue('orderway');
if (self::getValue('p'))
$no_duplication .= ($no_duplication != ""?" #":"#").self::getValue('p');
if (self::getValue('n'))
$no_duplication .= ($no_duplication != ""?" ":"").self::getValue('n');
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('orderby'))
$no_duplication .= self::getValue('orderby')." ".self::getValue('orderway');
if (self::getValue('p'))
$no_duplication .= ($no_duplication != ""?" #":"#").self::getValue('p');
if (self::getValue('n'))
$no_duplication .= ($no_duplication != ""?" ":"").self::getValue('n');
if ($no_duplication != "")
{
$ret['meta_title'] .= " (".$no_duplication.")";
$ret['meta_description'] .= " (".$no_duplication.")";
}
return $ret;
}


For more SEO tips check out http://www.presto-ch...estashopseotips
http://www.Presto-Changeo.com Prestashop Modules and Website Development
Modules: Attribute Wizard Pro | Ajax Filter | Website Translator | Facebook Comments | Mass Combination Editor | Database Export | Private Shop |Product List Attributes | OSC to PS Migration | ZenCart to PS | Cre-loaded to PS | Authorize.net | Sagepay | Fedex | UPS | USPS | Canada Post | Australia Post
Free Modules: Facebook Like | Google +1 | Rotating Fading Text | Quantity Discounts | Order IP Log
For the latest modules, updates and monthly discount coupons, follow Twitter or Facebook

Featured Module: Automatic Prestashop Backup - Backup your files and database on Amazon S3 Cloud server, locally, and via email for 3 layers of protection against data loss or server crash!

#2

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 25 April 2010 - 08:02 PM

Actually you can use Google webmaster tools to have Google ignore the parameters orderway and orderby, then they will all appear as the same page. This way you won't have to compromise the integrity of core files.

#3

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 25 April 2010 - 08:07 PM

From 1272222144:

Actually you can use Google webmaster tools to have Google ignore the parameters orderway and orderby, then they will all appear as the same page. This way you won't have to compromise the integrity of core files.


This is a much safer way, and will also affect other search engines that do not offer that option.

#4

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 25 April 2010 - 08:30 PM

From 1272222454:

From 1272222144:

Actually you can use Google webmaster tools to have Google ignore the parameters orderway and orderby, then they will all appear as the same page. This way you won't have to compromise the integrity of core files.


This is a much safer way, and will also affect other search engines that do not offer that option.


We will have to agree to disagree on this. This method adds words to the meta tags that you normally may not want, reduces the focus on the actual descriptive text etc.
You can also use robots.txt to block crawling of these pages with unwanted parameters. But that is slightly risky and requires careful examination before implementing.

#5

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 27 April 2010 - 04:19 PM

I have just updated this code (In the first post) to display the additional text for the description better (it was not showing is some cases).

I use a similar technique on TennisLessons.com, the site is ranked in the top 5 for tennis lessons + any city and it gets over 20,000 visitors a month from natural search engine results.

#6

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 30 April 2010 - 09:55 AM

Hi, is this problem solved in the lasted version 1.3.0.6? Do we still need to modify the code manually?

#7

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 30 April 2010 - 10:23 AM

This is'nt a bad ay to do it.

Only if you use the categories as landingpages (i do) could'nt it ceate keyword canibalisem? I will now be having 4+ pages that uses the same keyword's wouldnt the best way to use robots.txt to exclude the sites? Offcouse this would exclude some products from being indexed?

#8

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 08 May 2010 - 02:54 PM

Just updated the code in the first post to include additional pages (new products, best sellers, etc...)

#9

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 14 May 2010 - 08:51 AM

This is a nice way to deal with this problem. I'm not much of a coder so I can not understand exactly what is being changed. Is there any visible changes so I will know if the code works or not. ie in the url or with tools

#10

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 14 May 2010 - 09:13 AM

Tomerg,
Have ben slowly going through the changes made by adding your code to the tools.php, installing your 301 mod and edited the htaccess.

I notice that i now get two urls which point to the same page. Neither is redirecting so am i right in saying that i still have duplicate urls? That is how Google seems to be reading them.

They read:

n=10&orderby=position&orderway=desc&p=3
and,
n=10&orderby=position&orderway=desc&p=3&id_category=27

As I say, both land on the same page but the URL remain different in the address bar. I am assuming the first url here is the one that your suggestions/tools.php edits/module, etc have created, yes?

#11

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 18 May 2010 - 07:12 AM

From 1273326850:

Just updated the code in the first post to include additional pages (new products, best sellers, etc...)


Hi Tomer,

With new-products.php it does not work.
Why?

Thank you in advance for the answer.

#12

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 18 May 2010 - 02:01 PM

Did you also change getHomeMetaTags?

That takes care of the new-product / best-seller etc... pages.

#13

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 18 May 2010 - 02:59 PM

Hi Tomer,

Now it's all OK

But in page http://www.presto-ch...estashopseotips


you write "(unless manually changed)" : it was my case and i'd not change. Now I've change and it's all right.

Thank you very much!!!

Marcel.

#14

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 19 May 2010 - 05:26 AM

This have done wounders for my page, along with his Duplicate URL Redirect v1.1.9 payed module!! Go fore it guys!

#15

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 20 May 2010 - 07:59 PM

Im using these changes, but have these problemes:

Kvalitets bluser, som samtidigt er billige bluser. Bluser til mange formål. (name asc #5)
/shop/10-bluser?side=10&;varekat=&;p=5&orderby=name&orderway=asc&p=5

/shop/10-bluser?side=2&;varekat=1-2-3&;p=5&orderby=name&orderway=asc&p=5

/shop/10-bluser?side=6&;varekat=&orderby=name&orderway=asc&p=5

/shop/10-bluser?varekat=2&;p=4&orderby=name&orderway=asc&p=5

What am i missing?

#16

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 25 May 2010 - 01:19 PM

you seem to have other variables in the category page ("side" and "varekat"), you can add their values to the meta tags so they will be unique.

if (self::getValue('side'))
$no_duplication .= ($no_duplication != ""?" ":"").self::getValue('side');


#17

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 26 May 2010 - 04:21 PM

Works perfectly, thank you!

I do not see the lang parameters in the code, how could I change the text to appropriate language (price asc 30)?

#18

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 27 May 2010 - 06:51 PM

I found a minor "bug" in this (wich btw is great!)

When changing sort, product page, number of products shown the URL is not completly the same all the way.

A short exampel:
pressed in order sort -> page -> numbers returns the URL:
4-sexet-toj?n=10&orderby=price&orderway=asc&p=2

Now i press sort to something else and returns to price and asc and this gives the URL:
4-sexet-toj?n=10&p=2&orderby=price&orderway=asc

Notice how the p=2 has moved.

These to URL's has the same content, and same meta title and decription useing these changes. Therefor i took matters in my own hands and made some changes to tomer3 code.
static public function completeMetaTags($metaTags, $defaultValue)
{
global $cookie;
$no_duplication = "";
$input_url = $_SERVER['REQUEST_URI'];
$all_vars = explode("?", $input_url);
$spec_vars = explode("&", $all_vars[1]);
$loop = 0;
//$no_duplication .= print_r($all_vars);
while($spec_vars[$loop]) {
$type_and_var = explode("=", $spec_vars[$loop]);
if (($type_and_var[0] == 'p') || ($type_and_var[0] == 'orderby') || ($type_and_var[0] == 'orderway') || ($type_and_var[0] == 'n')) {
if ($type_and_var[0] == 'p') { $no_duplication .= '#'.$type_and_var[1].' '; }
else { $no_duplication .= $type_and_var[1].' '; }
}
$loop++;
}
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;
}


And

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 = "";
$input_url = $_SERVER['REQUEST_URI'];
$all_vars = explode("?", $input_url);
$spec_vars = explode("&", $all_vars[1]);
$loop = 0;
//$no_duplication .= print_r($all_vars);
while($spec_vars[$loop]) {
$type_and_var = explode("=", $spec_vars[$loop]);
if (($type_and_var[0] == 'p') || ($type_and_var[0] == 'orderby') || ($type_and_var[0] == 'orderway') || ($type_and_var[0] == 'n')) {
if ($type_and_var[0] == 'p') { $no_duplication .= '#'.$type_and_var[1].' '; }
else { $no_duplication .= $type_and_var[1].' '; }
}
$loop++;
}
if ($no_duplication != "")
{
$ret['meta_title'] .= " ( ".$no_duplication.")";
$ret['meta_description'] .= " ( ".$no_duplication.")";
}
return $ret;
}


All the credit should go to tomer3 for the inspiration for this change.

the number pr page does allso add id_category to the URL, wich kinda sucks to those how use rewrite, because this is allready in the URL. But i havent found the solution for this issue yet, but am working on it :)

#19

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 31 May 2010 - 04:10 PM

I have version 1.1.5 or in addition to friendly urls enabled

in google webmaster says I have a problem of meta tag dupliacacion

I can use this modification?

#20

    PrestaShop Newbie

  • 15 Dec 2011
  • Members
  • Pip
  • 0 posts

Posted 03 June 2010 - 07:46 PM

Hi all Presta SEO users

I read all the posts - but I still can't get Google to "act"...

My issues is:

We got this website http://www.cs-m.dk which we really try to improve on Google results.
But GWT keeps telling me that there are errors. Duplicate contents - and I now THIS punish the website hard...

SO:

1. The first error is trouble with the "duplicate meta descriptions" and
"Duplicate content orderby=name&orderway=asc" - and so on. Please see screendump 1.

2. The second error is that i get errors i GWT on the "Short meta descriptions". Please see screendump 2.

3. The third error is "Duplicate title tags" - Please see screendump 3.

4. My last problem is "Crawl errors" - see nr. 4 + 5

PLEASE HELP - how do I correct these errors. I have copied the new code posted in here to: /classes/tools.php - NO LUCK..!

Attached File(s)

  • Attached File  1.png (90bytes)
    Number of downloads: 999
  • Attached File  2.png (108bytes)
    Number of downloads: 940
  • Attached File  3.png (76bytes)
    Number of downloads: 901
  • Attached File  4.png (131bytes)
    Number of downloads: 899
  • Attached File  5.png (29bytes)
    Number of downloads: 883






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users