Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 07-10-2014 06:25:53

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Canonical Link Definitive Solution Please

Can we have a definitive working solution to printing accurate canonical links please. There are many posts on the subject in different threads with different solutions offered by both users and Kryptronic. It is impossible to know which one should be used. Please can we have clear guidance or a software update from Kryptronic that resolves this issue.

Google WMT is reporting a URL

http://www.quasarelectronics.co.uk/inde … ort=NAMEUP

This URL returns a page with the canonical link

<link rel="canonical" href="http://www.quasarelectronics.co.uk/" />

THIS IS BAD as the page is not our home page AND the page content is identical to the SEO optimised page at

http://www.quasarelectronics.co.uk/Cate … -recorders

The canonical on this page is correctly displayed as

<link rel="canonical" href="http://www.quasarelectronics.co.uk/Category/kits-modules-single-message-sound-recorders" />

The code we use to generate the canonical link is

Code:

<?php 
$canonicalurl = $this->globals('core.requesturi');
$canonicalurl = @strip_tags($canonicalurl);
$canonicalurl = $this->xhtml_encode($canonicalurl);
if (substr($canonicalurl, 0,44) === 'http://www.quasarelectronics.co.uk/index.php')
{print '<link rel="canonical" href="'.$this->globals('core_display.base_url') .'" />';}
else 
{print '<link rel="canonical" href="'. $canonicalurl .'" />';}
?>

Last edited by sdn (07-11-2014 12:05:55)


Simon

Offline

 

#2 07-10-2014 11:10:13

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

This is what I've been using:

Code:

$canonical = $this->globals('core.requesturi');
$canonical = preg_replace('/^' . preg_quote($this->globals('core.url_nonssl'),'/') . '/','',$canonical);
$canonical = preg_replace('/^' . preg_quote($this->globals('core.url_ssl'),'/') . '/','',$canonical);
$canonical = preg_replace('/\&amp\;/','&',$canonical);
$canonical = strip_tags($canonical);

if ($canonical == '/index.php') {

     $canonical = $this->link_namespace($this->globals('core.defaultapp'),$this->globals('core.defaultns'));
     $canonical = preg_replace('/^' . preg_quote($this->globals('core.url_nonssl'),'/') . '/','',$canonical);
     $canonical = preg_replace('/^' . preg_quote($this->globals('core.url_ssl'),'/') . '/','',$canonical);
     $canonical = preg_replace('/\&amp\;/','&',$canonical);

} // End of if statement.

print '<link rel="canonical" href="' . $this->xhtml_encode($canonical) . '" />' . $eol;

It works fine on kryptronic.com.  Added to {private}/core/CORE/includes/jslib.php.


Nick Hendler

Offline

 

#3 07-10-2014 11:28:24

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Canonical Link Definitive Solution Please

I have just tried this on the page example above. The canonical link is now:

<link rel="canonical" href="/index.php?app=ecom&ns=catshow&ref=1m800p370c10s&prodsort=NAMEUP" />

It is missing the base url. Google state you must use the absolute path in their article at

http://support.google.com/webmasters/an … 4617741#2.

The article also says "Don't specify different URLs as canonical for the same page (e.g. one URL in a sitemap and a different URL for that same page using rel="canonical").

This is a sorted category page. The canonical link should show the preferred (SEO optimised) URL:

<link rel="canonical" href="http://www.quasarelectronics.co.uk/Category/kits-modules-single-message-sound-recorders" />

Both page variations are <meta name="robots" content="index,follow" />

I was originally putting the code into the desktop skin only. Now it is in jslib the canonical link is also printed in the mobile version as this:

<link rel="canonical" href="/" />
.
Referring to another Google article at

https://developers.google.com/webmaster … es/details

Does CCP8 fall into the "Responsive" or "Dynamically Served" category? Should the canonical link served be the same as the desktop version?

We have URL parameters set but the site is not giving Google a clear and unambiguous message on these pages at present.

There is another interesting article on paginated content at

http://support.google.com/webmasters/an … ic=4617741

where they talk about using rel="next" and rel="prev". This would be useful for content that extends over more than 1 page.
At present Page 1 shows the correct seo rel canonical link but page 2 onward revert to the format in the example below:

http://www.quasarelectronics.co.uk/inde … ;offset=36

Last edited by sdn (07-11-2014 08:51:36)


Simon

Offline

 

#4 07-10-2014 16:37:28

magwa
Member
Registered: 09-22-2007
Posts: 321

Re: Canonical Link Definitive Solution Please

This issue regarding canonical URL's definitely needs sorting out. When reading the various posts on the subject nothing seems to be definitive and Google virutally demands there is no ambiguity on the matter.

Offline

 

#5 07-11-2014 10:21:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

We have the code above working on kryptronic.com.  I'm not quite sure that the full URL needs to be there, but here's the modified code to get that in there, and also to handle the URL a bit better for the case where CGI variables are present.  In jslib.php, remove this from the Google Analytics secion:

Code:

$requesturi = $this->globals('core.requesturi');
$requesturi = preg_replace('/^' . preg_quote($this->globals('core.url_nonssl'),'/') . '/','',$requesturi);
$requesturi = preg_replace('/^' . preg_quote($this->globals('core.url_ssl'),'/') . '/','',$requesturi);
$requesturi = preg_replace('/\&amp\;/','&',$requesturi);
$requesturi = preg_replace('/\'/','\\\'',$requesturi);

Then at the top of the file, right above the comment:

Code:

// +--
// | Handle Meta Tags and OpenGraph tags (If Interface Is Not BackEnd)
// +--

Add:

Code:

// +--
// | Request URI and Canonical URI
// +--

$requesturi        = '';
$canonical         = '';
$cgi_get_globals   = $this->globals('core.cgi_get_globals');
$requesturi_params = array();

if (!(empty($cgi_get_globals))) {

     foreach ($cgi_get_globals as $num => $name) {

          if ($name == 'ref') {

               $cgival = $this->globals('core_cgi.' . $name);

               if (is_array($cgival)) {foreach ($cgival as $cginum => $cgidata) {$requesturi_params[$name][] = $this->xhtml_translate($cgidata,'ENCODE');}}
               else                   {$requesturi_params[$name] = $this->xhtml_translate($cgival,'ENCODE');}

          } // End of if statement.

     } // End of foreach statement.

     $requesturi_app = $this->globals('core.app');
     $requesturi_ns  = $this->globals('core.namespace');

     $orig_robot     = $this->globals('core.robot');          $this->globals('core.robot','CORE_JSlib');
     $orig_uid       = $this->globals('core_user.id');        $this->globals('core_user.id','');
     $orig_group     = $this->globals('core_user.usergroup'); $this->globals('core_user.usergroup','');
     $orig_interface = $this->globals('core.interface');      $this->globals('core.interface','FrontEnd'); 

     $canonical  = $this->link_namespace($requesturi_app,$requesturi_ns,$requesturi_params);

     $this->globals('core.robot',$orig_robot);
     $this->globals('core_user.id',$orig_uid);
     $this->globals('core_user.usergroup',$orig_group);
     $this->globals('core.interface',$orig_interface);

} else {

     if ($_SERVER['SERVER_PORT'] != $this->globals('core.port_ssl')) {$canonical = $this->globals('core.url_nonssl') . '/';}
     else                                                            {$canonical = $this->globals('core.url_ssl') . '/';}

} // End of if statement.

$requesturi = $canonical;
$requesturi = preg_replace('/^' . preg_quote($this->globals('core.url_nonssl'),'/') . '/','',$requesturi);
$requesturi = preg_replace('/^' . preg_quote($this->globals('core.url_ssl'),'/') . '/','',$requesturi);
$requesturi = preg_replace('/\&amp\;/','&',$requesturi);
$requesturi = strip_tags($requesturi);

// +--
// | Canonical Tag
// +--

if (!(empty($canonical))) {

     print '<link rel="canonical" href="' . $this->xhtml_encode($canonical) . '" />' . $eol;

} // End of if statement.

This will delete all CGI variables which are not 'app', 'ns' or 'ref', and produce a full SEO-optimized URL for all requests, even those with CGI params for pagination, etc.


Nick Hendler

Offline

 

#6 07-11-2014 11:12:01

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Canonical Link Definitive Solution Please

Thanks. We are using the new analytics code so can I assume that the change above is compatible?

This new code appears to deal with "sorted" page variants but there is a problem with long lists (like AllItems) that extend over a series of pages. The same canonical link appears on every page in the series even though the content is different.

I also noticed that the first page uses the seo url but subsequent pages revert to a non-seo format like index.php?app=ecom&ns=prodall&ref=&count=60&offset=60.

Is there a way that the software can be made to produce seo urls on all pages in a series and add a number to the end (as is done for the page title) so that Google and users can see the page being viewed is part of a series e.g.

AllItems-page1
AllItems-page2, etc

The canonical link can then reflect this page numbering.

The article I mentioned earlier about paginated content also offers another solution using rel="next" and rel="prev" in the head:

http://support.google.com/webmasters/an … ic=4617741

Could that be generated?

In response to your comment about using the full url, Google state in the other article:
Avoid errors: use absolute paths rather than relative paths with the rel="canonical" link element.
Use this structure:  http://www.example.com/dresses/green/greendresss.html
Not this structure: /dresses/green/greendress.html)

Last edited by sdn (07-13-2014 04:31:23)


Simon

Offline

 

#7 07-14-2014 07:44:01

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

The above change is compatible with the Google anayltics code.  The canonical URL uses the full URL, whereas the requesturi (used for analytics) uses the short version.  The paginated results were purposely eliminated and combined into one canonical URL to avoid duplicate content issues.  The software could be made to handle the paginated results, but that would require serious SEO work either in the CORE_App class, or in the .htaccess file.  I'd recommend getting a custom shop quote on that.


Nick Hendler

Offline

 

#8 07-14-2014 16:22:50

josieboy
Member
Registered: 06-24-2014
Posts: 7

Re: Canonical Link Definitive Solution Please

webmaster wrote:

The software could be made to handle the paginated results, but that would require serious SEO work either in the CORE_App class, or in the .htaccess file.  I'd recommend getting a custom shop quote on that.

Im disappointed by this response as Google has been strongly emphasising for several years the importance of canonical url's. Spokesman MC's statements on the subject for the past two years have been quite clear about it and leave little room for doubt that a dim view is taken on incorrectly setup canonicals and for the software not to support them correctly is abysmal,

Im sorry Nick but your stat in another thread that canonicals are becoming popular with some people and you would probably support them at some point in the future is way short of what Ive come to expect from CCP

Offline

 

#9 07-14-2014 18:00:23

Graham
Member
Registered: 09-30-2004
Posts: 981
Website

Re: Canonical Link Definitive Solution Please

webmaster wrote:

The above change is compatible with the Google anayltics code.

Yet I'm still getting nothing from Google in-page analytics, but Crazy Egg's code works fine.

Offline

 

#10 07-15-2014 07:10:13

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Canonical Link Definitive Solution Please

Accurate canonical links seem to be a baseline requirement of any self-respecting shopping cart these days as intimated in your sales literature:

"Advanced Turbo-Charged Search Engine Optimization
Every building block of our ecommerce software has been thoroughly designed to give you the best possible chance of being noticed and also rising in the search engines. Every product, category and page can be individually optimized as well as your overall site."

If I had total control over the urls (as I did with our old hand coded html site that ranked extremely well but looked like a dog and became impossible to maintain) I would use SEO urls on each page in the series as outlined above (e.g. AllItems-page1, etc) with matching canonical links and rel="next" and rel="prev" in the head.

If the page was sorted it could revert to the index.php?app=ecom&ns=prodall&ref=&count=60&offset=60 parameter format as now but retain the same canonical data “AllItems-page1”. That way Google understand what is going on from the parameter data. How would that create duplicate content issues.

I do not claim to be an SEO expert but I do know what worked very well for us for over 15 years with our hard coded html site. The SEO performance of our CCP site is less than half as good so there is still a long way to go before it becomes turbo charged from our perspective.

Last edited by sdn (07-15-2014 07:54:58)


Simon

Offline

 

#11 07-15-2014 10:05:09

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

I can appreciate that.  We'll be adding the canonical tag to the next release.  It will work fully, with support for pagination.  The modifications listed here on the forum get you 90% of what you need for the canonical tag.  Kryptronic can either bring it home for you through our custom shop, or you can update the software when we release a new version with canonical tag support.


Nick Hendler

Offline

 

#12 07-15-2014 10:30:25

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Canonical Link Definitive Solution Please

I appreciated that the new coding is a considerable improvement over the previous one. We will await the new version/update(?). Is there any indication of a release date for this?

In the meantime, where are the hyperlinks generated for the 2nd, 3rd, etc. pages that appear in the defaultlink div on a page?


Simon

Offline

 

#13 07-16-2014 11:09:35

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

Update timeframe is not set, but I'd like to get something out by the end of August.

Edit the {private}/apps/ecom/ECOM/includes/navarray.php file to edit the pagination links.


Nick Hendler

Offline

 

#14 10-23-2014 12:31:41

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Canonical Link Definitive Solution Please

It looks like the canonical metatag code did not make it into the 8.0.8 release so I would like to put it in myself.

The 8.0.8 jslib.php code appears to have changed a bit so not sure if the mod in the post above (07-11-2014 16:21:52) is still OK to use. Please can you confirm?


Simon

Offline

 

#15 10-24-2014 07:52:32

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

Yes, that code can be inserted.


Nick Hendler

Offline

 

#16 01-31-2015 13:23:50

amdowney
Member
From: UK-Warwickshire
Registered: 09-21-2007
Posts: 507
Website

Re: Canonical Link Definitive Solution Please

Did anything get released to optimise pagination?

Offline

 

#17 02-02-2015 10:47:44

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Canonical Link Definitive Solution Please

Not in relation to canonical URLs.  The software does provide proper pagination in the meta tags.


Nick Hendler

Offline

 

Board footer