Zen Cart Logo
Forums / General Questions / product page missing "canonical"

product page missing "canonical"

Views: 1,065

Results 1 to 11 of 11
24 Apr 2019, 2:42 AM
#1
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

product page missing "canonical"

Couple of days ago , everything is fine.
I didn't touch anything but today , I noticed all of my product page source code missing the "<link rel="canonical"
So I went to /includes/templates/My Template/common/html_header.php to check, the code is right there:

<?php if (isset($canonicalLink) && $canonicalLink != '') { ?> <link rel="canonical" href="<?php echo $canonicalLink; ?>" /> <?php } ?>

Can anybody tell me what makes the canonical missing in product page code?:frusty::frusty:

24 Apr 2019, 2:49 AM
#2
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

Ok, I found out if I turn on the "Ceon URI Mapping ", the "<link rel="canonical" part shows back up in the html source code.
but if I turn off the "Ceon URI Mapping ", then the problems come back, can anyone guide me how to fix it:

I need to turn off the CEON URI mapping while keep the canonical part

24 Apr 2019, 4:30 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: product page missing "canonical"

There is an override file applied for Ceon URI Mapping, though as I seem to recall with ZC 1.5.0, a site that was served with https didn't present a canonical link on those pages.

Anyways, would recommend removing includes/auto_loaders/overrides/canonical_link.php from the load sequence so that the core version of the file would be loaded (though again I seem to recall that the canonical link for an https page was not provided back in ZC 1.5.0 but that's been 7ish years since I worked with it).

24 Apr 2019, 5:03 AM
#4
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

Mc12345678, I did what you said but there is no such a file in the path you mentioned.

I go to includes/init_includes/overrides/ to find the file named init_canonical.php, the one CEON mod brought and removed it, still not luck .

24 Apr 2019, 5:09 AM
#5
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

I don't have to turn off CEON, but it create a URL unmatch problem:

when CEON is on, my product 1 url reads like : https:/mysite.com/categoryname/product1 name

then if I create a sitemap, the above URL will be stored,

However, google bot crawls it like : https:/mysite.com/categoryname/product1 name?cPath=categoryname

you can see the difference, so google bot think the product URL is NOT in my sitemap!

I need those two URL to be the same so I have to shut down CEON, but this move kills the canonical tag in the header

PLease help!

24 Apr 2019, 5:23 AM
#6
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

sorry, google bot will read the product url like https:/mysite.com/categoryname/product1 name?cPath=categoryID

24 Apr 2019, 7:57 AM
#7
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

mc12345678,
I unstalled the CEON URI mapping, and recover with all original files, still no canonical tag in the header.
I also tried different templates, none of them works, but when I open the html_header.php to check, the code is right there:

<?php if (isset($canonicalLink) && $canonicalLink != '') { ?> <link rel="canonical" href="<?php echo $canonicalLink; ?>" /> <?php } ?>

But it just can't work? Do you know why?

24 Apr 2019, 12:21 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: product page missing "canonical"

sjbglx1:

mc12345678,
I unstalled the CEON URI mapping, and recover with all original files, still no canonical tag in the header.
I also tried different templates, none of them works, but when I open the html_header.php to check, the code is right there:

<?php if (isset($canonicalLink) && $canonicalLink != '') { ?> <link rel="canonical" href="<?php echo $canonicalLink; ?>" /> <?php } ?>

But it just can't work? Do you know why?
Yes, because prior to production release of ZC 1.5.3 (initially modified in the not released for production version 1.5.2) if the page visited is served as https: then the canonical link was not generated. At the time of development/use, the consideration remained that only pages that needed to be served via https were presented using https. That meant pages like signin, checkout_, etc... These were pages basically that would not have a "need" to be indexed. Then came along the idea by the general public that all pages probably should be served using https:. At about that same time Zen Cart had to release a new version so that it would operate using the then current version of PHP. From that point onwards a new version has been issued whenever the software had significant incompatibility with available (and current) php versions.

So. The absence of a canonical link when NOT using Ceon URI Mapping is essentially because of the version of Zen Cart being used. More recent versions (beginning at Zen Cart 1.5.3) have a modification in includes/init_includes/init_canonical.php that will present the canonical link for a page served using https if the whole site is served using https: as configured at: https://www.zen-cart.com/content.php?56-how-do-i-enable-ssl-after-i-have-installed-zen-cart

25 Apr 2019, 1:02 AM
#9
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

Thank you so much!

I will read that thread for now!

25 Apr 2019, 1:14 AM
#10
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

mc12345678,
I read that thread and I understand what it says.
My question is : due to the special condition of my site, I can only use zen cart version 1.5.0 or 1.5.1, since some mods I relied on only works on these two version.
I can not survive without those mods while they stop upgrading to higher versions.

To make canonical tag work while using https version of my site, can I borrow the file includes/init_includes/init_canonical.php from 1.5.3 version, and replace it in 1.5.0 version to reach my goal?

25 Apr 2019, 1:29 AM
#11
sjbglx1 avatar

sjbglx1

New Zenner

Join Date:
May 2015
Location:
AU
Posts:
52
Plugin Contributions:
0

Re: product page missing "canonical"

I tried to use the newer file you mentioned to replace the old one, only that very file, and now it works!! I use https to show product page and canonical tag back on my header! So happy to learn this!!!

Thank you!!!!