News:

Support the VirtueMart project and become a member

Main Menu

absolute canonical

Started by zampa, November 15, 2014, 16:15:04 PM

Previous topic - Next topic

zampa

Sorry for my english in advance.
I want that canonical URL are an absolute URL. In version 2.0.20b, I modified (components/com_virtuemart/views/productdetails/view.html.php):
   if ($format == 'html') {

       // Set Canonic link

       $document->addHeadLink(JRoute::_($product->canonical, true, 0), 'canonical', 'rel', '');

   }

changing 0 by -1:
   if ($format == 'html') {

       // Set Canonic link

       $document->addHeadLink(JRoute::_($product->canonical, true, -1), 'canonical', 'rel', '');

   }

in 2.6.12 dont work anymore and I dont know how to do.
Thanks.
In advance.

jjk

I didn't try your hack to come up with an absolute canonical URL, but I assume that the reason for your wish is this article at Google Webmaster tools:
https://support.google.com/webmasters/answer/139066?hl=en

It says:
QuoteAvoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.
Use this structure:  ...//www.example.com/dresses/green/greendresss.html
Not this structure: /dresses/green/greendress.html).

However, in my opinion the reason why they recommend the absolute URL is, that it's relatively easy to send their crawler into a loop when the website doesn't use the relative canonical urls correctly.

But in VirtueMart the relative canonical URLs are built correctly. I don't see any disadvantage using them. There is another Google article about this in the Google Webmaster Central Blog at http://googlewebmastercentral.blogspot.de/2013/04/5-common-mistakes-with-relcanonical.html

If you look at the image below "Mistake 2: Absolute URLs mistakenly written as relative URLs ", you will see that the type of relative canonical URLs VirtueMart produces are marked green, which is ok for Google.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

zampa

#2
Quote from: jjk on November 24, 2014, 10:27:01 AM
I didn't try your hack to come up with an absolute canonical URL, but I assume that the reason for your wish is this article at Google Webmaster tools:
https://support.google.com/webmasters/answer/139066?hl=en

It says:
QuoteAvoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.
Use this structure:  ...//www.example.com/dresses/green/greendresss.html
Not this structure: /dresses/green/greendress.html).

However, in my opinion the reason why they recommend the absolute URL is, that it's relatively easy to send their crawler into a loop when the website doesn't use the relative canonical urls correctly.

But in VirtueMart the relative canonical URLs are built correctly. I don't see any disadvantage using them. There is another Google article about this in the Google Webmaster Central Blog at http://googlewebmastercentral.blogspot.de/2013/04/5-common-mistakes-with-relcanonical.html

If you look at the image below "Mistake 2: Absolute URLs mistakenly written as relative URLs ", you will see that the type of relative canonical URLs VirtueMart produces are marked green, which is ok for Google.
Thanks. I don't very sure about that: I changed from virtuemart 2.b by write data over a clean virtuemart (over a clean joomla) and I lost a lot of indexed links in google, and it raises very slow (perhaps by the speed in read or another stuff).
Anyway I did this and it seems to work:
around line 797 in administrator/component/virtuemart/models/product I replaced this
$child->canonical = JRoute::_ ($child->canonical,FALSE);
by
$child->canonical = 'http://www.MYSITE.com'.JRoute::_ ($child->canonical,FALSE);


similarly for category aroun line 311 (not in administrator folder) in components/com_virtuemart/views/category/view.html.php by change
$document->addHeadLink( JRoute::_($link, FALSE) , 'canonical', 'rel', '' );
by
$document->addHeadLink('http://www.MYSITE.COM'.JRoute::_($link, FALSE) , 'canonical', 'rel', '' );

zampa

Quote from: zampa on December 09, 2014, 11:12:13 AM
Quote from: jjk on November 24, 2014, 10:27:01 AM
I didn't try your hack to come up with an absolute canonical URL, but I assume that the reason for your wish is this article at Google Webmaster tools:
https://support.google.com/webmasters/answer/139066?hl=en

It says:
QuoteAvoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.
Use this structure:  ...//www.example.com/dresses/green/greendresss.html
Not this structure: /dresses/green/greendress.html).

However, in my opinion the reason why they recommend the absolute URL is, that it's relatively easy to send their crawler into a loop when the website doesn't use the relative canonical urls correctly.

But in VirtueMart the relative canonical URLs are built correctly. I don't see any disadvantage using them. There is another Google article about this in the Google Webmaster Central Blog at http://googlewebmastercentral.blogspot.de/2013/04/5-common-mistakes-with-relcanonical.html

If you look at the image below "Mistake 2: Absolute URLs mistakenly written as relative URLs ", you will see that the type of relative canonical URLs VirtueMart produces are marked green, which is ok for Google.
Thanks. I don't very sure about that: I changed from virtuemart 2.b by write data over a clean virtuemart (over a clean joomla) and I lost a lot of indexed links in google, and it raises very slow (perhaps by the speed in read or another stuff).
Anyway I did this and it seems to work:
around line 797 in administrator/component/virtuemart/models/product I replaced this
$child->canonical = JRoute::_ ($child->canonical,FALSE);
by
$child->canonical = 'http://www.MYSITE.com'.JRoute::_ ($child->canonical,FALSE);


similarly for category aroun line 311 (not in administrator folder) in components/com_virtuemart/views/category/view.html.php by change
$document->addHeadLink( JRoute::_($link, FALSE) , 'canonical', 'rel', '' );
by
$document->addHeadLink('http://www.MYSITE.COM'.JRoute::_($link, FALSE) , 'canonical', 'rel', '' );
I had a little problem with related products, when I have edited products and I had clicked over a related product I go to detail page in front end, not to edit this product.
I didn't notice that google indexes faster, but I noticed that google look at minor number of pages ( jumping duplicate ones, I guess) and find much structured data.