Hi there David,
Is it possible to integrate Google's new "canonical" meta tag into Price Tapestry to help avoid any duplicate content penalty?
I was thinking this could be used to eliminate duplicate content when sorting by Price (Low to High, High to Low)
&page=1&sort=priceAsc
&page=1&sort=priceDesc
(and also possibly for pages that use product reviews?)
<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish" />
I assume this would go into thehtml/header.php file but I'm not entirely sure how to strip the extra sort variables?
Thanks in advance, and I hope this feature might possibly help other users of PT?
Jim
--
More details here:
http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
we now support a format that allows you to publicly specify your preferred version of a URL. If your site has identical or vastly similar content that's accessible through multiple URLs, this format provides you with more control over the URL returned in search results. It also helps to make sure that properties such as link popularity are consolidated to your preferred version.
http://www.example.com/product.php?item=swedish-fish
http://www.example.com/product.php?item=swedish-fish&category=gummy-candy
http://www.example.com/product.php?item=swedish-fish&trackingid=1234&sessionid=5678
<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish" />
Great hack, I installed it,
but if I search a product, the result pages show the same rel=canonical and exclude &page number. I mean:
/search.php?q=iphone&page=2&sort=relevance
/search.php?q=iphone&page=3&sort=relevance
show ever rel=canonical /search.php?q=iphone
Is there a way to consider page=2 , page=3 as good, and exclude &sort=relevance ?
Thank you
Hi,
Sure - you can include the page parameter (if greater than 1) as follows:
<?php
if (isset($searchresults["numRows"]) && ($searchresults["numRows"]) && (!isset($rewrite)))
{
$canonical = $config_baseHREF."search.php?q=".urlencode($q);
if ($page > 1) $canonical .= "&page=".$page;
print "<link rel='canonical' href='".$canonical."' />";
}
?>
Cheers,
David.
Hello David,
I am facing the same duplicate Google issue, but as I tried to implement the code, the following error occured
Notice: Undefined variable: searchresults
How can I apply the correct code.
Thanks you for your support
Have a nice day
Steve
Hello Steve,
Use the updated replacement above, with the addition of an isset() check to remove the errors.
Cheers,
David.
--
PriceTapestry.com
Hi Jim,
Yes, this can be done easily in html/header.php, using $_GET["rewrite"] to check that the page has NOT been generated with a search engine friendly URL in the first place. The following code should do the trick (insert before the
</head>
HTML):<?php
if (($searchresults["numRows"]) && (!$_GET["rewrite"]))
{
print "<link rel='canonical' href='".$config_baseHREF."search.php?q=".urlencode($q)."' />";
}
?>
Cheers,
David.