News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

rel="prev" / rel="next" / canonical

Started by -Tony-, August 31, 2015, 15:40:19 PM

Previous topic - Next topic

-Tony-

Hello
Virtuemart 3.0.9
I tried a little thing to improve my seo on category pages.
Basic virtuemart adds the canonical tag on all category pages, but the canonical tag does not include basic pagination ("? Start = X"), the canonical page it's the first page, for all pages.
And I think this is not good because it is said to robots "all other pages are duplicate content, the good page it's the first one".
This is true for sorting pages (orderby=X) or when displaying x results per page (limit=X), but not for basic pages with pagination "? Start = X".
So I added links with rel = "prev" and rel = "next" and the canonical tag with pagination on category pages.
So in category / default.php (after unset the joomla & virtuemart canonical tag) I added:

$pagdata = $this->vmPagination->getData();
$myUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$myUrl=str_replace( '?limitstart=0', '', $myUrl); //duplicate for first page
$document->addHeadLink($myUrl, 'canonical', 'rel');
if($pagdata->next->link){$document->addHeadLink(JRoute::_($pagdata->next->link), 'next', 'rel');}
if($pagdata->previous->link){$document->addHeadLink(JRoute::_($pagdata->previous->link), 'prev', 'rel');}


And in robots.txt:


Disallow: /*orderby=*
Disallow: /*limit=*


For not using robots.txt I tried:


$myUrl=str_replace( '&orderby=product_price', '', $myUrl);
$myUrl=str_replace( '&orderby=product_name', '', $myUrl);
$myUrl=str_replace( '&limit=40', '', $myUrl);
etc,etc...


But I had collateral effects.

So this example gives, for example:

For the first page :

<link href="http://www.mydomain.com/shop/categorypage" rel="canonical" />
<link href="http://www.mydomain.com/shop/categorypage?start=20" rel="next" />

For the second page :

<link href="http://www.mydomain.com/shop/categorypage?limitstart=0" rel="prev" />
<link href="http://www.mydomain.com/shop/categorypage?start=20" rel="canonical" />
<link href="http://www.mydomain.com/shop/categorypage?start=40" rel="next" />

etc.....

I know my code is really dirty, it can be improved (best way for $myUrl ? ) and that's why I post, but it works^^ and the idea is here and I do not have the skills to go further.
Regards.

EDIT :

finally no collateral effets, just my cache, so i added :


$myUrl=str_replace( '?limitstart=0', '', $monUrl);
$myUrl=str_replace( '&limitstart=0', '', $monUrl);
$myUrl=str_replace( '?limit=20', '', $monUrl);
$myUrl=str_replace( '?limit=40', '', $monUrl);
$myUrl=str_replace( '?limit=80', '', $monUrl);
$myUrl=str_replace( '?limit=200', '', $monUrl);
$myUrl=str_replace( '&limit=20', '', $monUrl);
$myUrl=str_replace( '&limit=40', '', $monUrl);
$myUrl=str_replace( '&limit=80', '', $monUrl);
$myUrl=str_replace( '&limit=200', '', $monUrl);
$myUrl=str_replace( '?orderby=product_price', '', $monUrl);
$myUrl=str_replace( '&orderby=product_price', '', $monUrl);
$myUrl=str_replace( '?orderby=product_name', '', $monUrl);
$myUrl=str_replace( '&orderby=product_name', '', $monUrl);
//I tried to group all terms in a single variable but i've failed...

but I still keep the instructions in the robots.txt

GJC Web Design

Have u checked the canonicals in 3.0.9.6?  3.0.9 is quite old now and there are a lot of changes since..
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

-Tony-

#2
Hi
Thanks for your reply.
Yes the update are done and I looked.
But the canonical tag is the same for all category pages paginated. The first page.
Finally I managed to do what I wanted. It works well for me and my website.

category / default.php:



$document = JFactory::getDocument ();
$pagdata = $this->vmPagination->getData();
$next = JRoute::_($pagdata->next->link);
$prev = JRoute::_($pagdata->previous->link);

$prev=str_replace( '?limitstart=0', '', $prev);
$prev=str_replace( '&limitstart=0', '', $prev);

$myUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$myUrl=str_replace( '?error=404', '', $myUrl);
$myUrl=str_replace( '?limitstart=0', '', $myUrl);
$myUrl=str_replace( '&limitstart=0', '', $myUrl);
$myUrl=str_replace( '?limit=20', '', $myUrl);
$myUrl=str_replace( '?limit=40', '', $myUrl);
$myUrl=str_replace( '?limit=80', '', $myUrl);
$myUrl=str_replace( '?limit=200', '', $myUrl);
$myUrl=str_replace( '&limit=20', '', $myUrl);
$myUrl=str_replace( '&limit=40', '', $myUrl);
$myUrl=str_replace( '&limit=80', '', $myUrl);
$myUrl=str_replace( '&limit=200', '', $myUrl);
$myUrl=str_replace( '&start=40', '?start=40', $myUrl);
$myUrl=str_replace( '&start=80', '?start=80', $myUrl);
$myUrl=str_replace( '&start=800', '', $myUrl);
$myUrl=str_replace( '?start=800', '', $myUrl);
$myUrl=str_replace( '?dir=DESC', '', $myUrl);
$myUrl=str_replace( '&dir=DESC', '', $myUrl);
$myUrl=str_replace( '?orderby=product_price', '', $myUrl);
$myUrl=str_replace( '&orderby=product_price', '', $myUrl);
$myUrl=str_replace( '?orderby=product_name', '', $myUrl);
$myUrl=str_replace( '&orderby=product_name', '', $myUrl);

if (empty($this->keyword)) {$document->addHeadLink($myUrl, 'canonical', 'rel');}

if (empty($this->keyword) && ($pagdata->next->link)){$document->addHeadLink($next, 'next', 'rel');}

if (empty($this->keyword) && ($pagdata->previous->link)){$document->addHeadLink($prev, 'prev', 'rel');}



and template / logic.php:




$document = JFactory::getDocument();

if (preg_match("#users|error|Itemid|keyword|limitstart|orderby|contact|legales|conditions|limit|DESC|Desc|notify|feed|index.php|undefined|tmpl|PageSpeed|productsublayout#",$_SERVER['REQUEST_URI'])){$document->setMetaData( 'robots', 'noindex, follow' );}



Regards

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

-Tony-

#4
Hi
Thanks, i've update and try in website dev.
But that's not really what i mean.
Let me explain more in details what i see good basic seo on category page, for google friendly and 0 duplicate.

Take the example of a model like this, with by default 20 products per page and 3 pages and when manufacturer = 0

*****************************************************************************

Currently in 3.0.9.10 the result is :

For basic pagination :

For the first page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>

For the second page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>

For the third page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=40
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>

For pagination + filters examples = DC :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20&orderby=product_XX
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limit=40&start=80
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limit=40&limitstart=0
<head>
<link href="/joomlahomepage/virtuemarthomepage/categorypage/manufacturer/" rel="canonical" />
</head>


Notes :

-Canonical are wrong when manufacturer = 0
-I think cannonical url must be absolute and not relative
-Canonical it's the same for all basic pagination (?start=X) so for google the good page are the first one, all other pages are DC
-I see your rel/prev add in html source and vmpagination.php, but for me i think rel/prev must be in the head in <link href="X" rel="next" />, not in the body in <li><a rel="next" href="X" >X</a></li>
-Canonical tag is not enough i think, because duplicate pages can still be indexed, it happens, canonical is a suggestion, not an order. Noindex is an order.

**********************************************************************************

On my website with my dirty hack and how I think things should be:

For basic pagination :

For the first page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?start=20" rel="next" />
</head>

For the second page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage" rel="prev" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?start=40" rel="next" />
</head>

For the third page :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=40
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=40" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?start=20" rel="prev" />
</head>

For pagination + filters examples = DC  :

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20&orderby=product_XX
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=20" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&start=40" rel="next" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limitstart=0" rel="prev" />
<meta name="robots" content="noindex, follow" />
</head>

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limit=40&start=80
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?start=80" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_price&limit=40&start=40" rel="prev" />
<meta name="robots" content="noindex, follow" />
</head>

URL : mydomain.com/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limit=40&limitstart=0
<head>
<link href="http://www.mydomain.com/joomlahomepage/virtuemarthomepage/categorypage" rel="canonical" />
<link href="/joomlahomepage/virtuemarthomepage/categorypage?orderby=product_XX&limit=40&start=40" rel="next" />
<meta name="robots" content="noindex, follow" />
</head>


Notes :

-Googlebot understand now page1, page2(?start=20), page3(?start=40) are ONE PAGE and prefer the first in serps
-Canonical are ok for first and paginated pages
-noindex on all duplicated pages
-follow and not nofollow, because he must crawl the page to see the canonical, and especially in case of backlink pointing on DC page, seo juice is transferred to the canonical page.
-rel and prev link are relative in my example, but i think is better if in absolute.
-I'm note sure my canonical on filter parameters was ok, but noindex is here.


http://googlewebmastercentral.blogspot.fr/2011/09/pagination-with-relnext-and-relprev.html


Regards
Tony









Studio 42

Hi,
I fixed this on changing in router.php:
function virtuemartBuildRoute
in
case : category
if ( isset($query['virtuemart_manufacturer_id'])  ) {
to
if ( !empty($query['virtuemart_manufacturer_id'])  ) {