Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

ht_canonical in other pages


Ken44

Recommended Posts

Hi

 

I almost posted this in the SEO Reloaded thread but after looking at the code I think it belongs here.

 

Anyway, the problem is that the ht_canonical.php is not creating canonical urls for products_new.php, specials.php and product_reviews.php

 

Regards

 

Ken

Link to comment
Share on other sites

@@Ken44 - it belongs in neither ;)

The out of the box osC file, ht_canonical.php, produces canonical URLs only for FILENAME_DEFAULT and FILENAME_PRODUCT_INFO ...

 

I’m already seeing duplicate content in Google Webmaster Tools from new products and there is not a single contribution in the Add-Ons to fix (only) this.

ht_canonical.php was added to 2.3.3 in 2012. So this is not just a Bootstrap problem, all shops running 2.3.3 and using the inbuilt header tags must be seeing duplicate content. :(

 

Regards

 

Ken.

Link to comment
Share on other sites

I would not advise to use this addon as it stands, unfortunately. What you've done is canonicalized the pagination of (eg specials) to just the first page of special offers => you've introduced something undesirable (in my opinion)..

Link to comment
Share on other sites

you've introduced something undesirable (in my opinion)..

 

I agree - but this is now working in the same way as the original ht_canonical.php.

 

/index.php?cPath=1_7&sort=2a&page=3

gives a canonical of

/index.php?cPath=1_7

 

/index.php?cPath=1_7&sort=2d&page=6

gives a canonical of

/index.php?cPath=1_7

 

The code will prevent duplicates but pagination does need to be added.

 

And It also should be added to categories and manufacturers. - Should I post this as a bug report?

 

 

Regards

 

Ken

Link to comment
Share on other sites

@@Ken44 Regarding your comment about duplicate content,

I’m already seeing duplicate content in Google Webmaster Tools from new products and there is not a single contribution in the Add-Ons to fix (only) this.

You are not seeing duplicate content. It's duplicate titles, descriptions or something like that. That is totally different. Seeing it as duplicate content is a common mistake. Google is just letting you know that you have products, or whatever, on your site that have the same title, or whatever, as some other product. This is not necessarily a mistake but it is not usually correct since, ideally, you want every item in the shop to have unique title and tags.

 

Regarding the canonical meta tag, yes, it should be on any page where there can be more than one version of that page, like when multiple pages or sorting is involved. The canonical tag should point to the preferred page, which is usually the first instance of the page. So index.php?cPath=1_7&sort=2d&page=6 should have a canonical tag of index.php?cPath=1_7. In the case of the new products page, products_new.php?page=2 should have a canonical tag of products_new.php. So the preferred url varies with the page involved. If you look at the products_new.php page on my site, you will see how Header Tags SEO handles it.

 

In your google webmaster tools account, you can use the parameter handling section to tell them how to handle those. But that doesn't help with the other search engines so it is best to do it on the site too.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@@Jack_mcs

You've introduced the exact same problem on your site. http://www.oscommerce-xxxxxxxx.com/products_new.php?page=2'>http://www.oscommerce-xxxxxxxx.com/products_new.php?page=2 looking at the cource code gives a canonical of http://www.oscommerce-xxxxxxxx.com/products_new.php which is undesirable, you've canonicalized 245 products all the way down to 10 products - that's not helpful for SEO.

 

@@Ken44

You should be using rel=prev and rel=next (which would be a PITA to code up in a manner consistent with modern 2.3 Header Tag code) or to link to a page that shows all of the products in one go (and same for any page that uses the splitPageResults function).

 

This definitely needs attention, raise it as a bug.

Link to comment
Share on other sites

@@burt To be honest, I don't use that page on my site so I don't really look at it. It may have been a bad example since it only deals with pagination. I'll have to look into this.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@@burt To be honest, I don't use that page on my site so I don't really look at it. It may have been a bad example since it only deals with pagination. I'll have to look into this.

 

I don't think it's a bug at your end (well it is, but you know what I mean, it's more an bug in the core that has needs addressing) - it's something we need to look at. Google say use rel=prev and rel=next, but that would be so much code to achieve little. Another option according to Google is "show all" page - my thought is to add a link to the canonical "&view=all", then pickup the $_GET['view'] in the product_listings module and if so set the splitpageresult to something like 10000 (thereby showing all the products).

 

However, I'm not certain that doing that is best - what do you think is the most products on a given page that can be handled in terms of a page that Google will return in SERPS ? Take for eg, products_new.php in a shop that has 6000 products. Show all 6000 ? That seems wrong to me, whats your view?

Link to comment
Share on other sites

However, I'm not certain that doing that is best - what do you think is the most products on a given page that can be handled in terms of a page that Google will return in SERPS ? Take for eg, products_new.php in a shop that has 6000 products. Show all 6000 ? That seems wrong to me, whats your view?

I run into this fairly often when working on sites. Shop owners want to display a lot of products but it causes too much of a slow down. On a site like mine, where images are not used, I may be able to get away with a large number of listings, though probably not 6,000. But on most shops, a few hundred can kill it, even with an image thumbnailer. The search engines won't wait a long time for a page to load, nor will customers. And since the page has to be viewable by the customers, that would probably result in a lot of them being aggravated at having to wait. Probably the best thing to do with it is nothing, as you originally stated.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Hi.

 

Here is an example of some duplicate content from Google > Webmaster Central > HTML Improvements.

 

New Products

/products_new.php?max=42&sort=3a&page=27

/products_new.php?max=63&sort=3a&page=29

/products_new.php?max=63&sort=3d&page=23

/products_new.php?max=84&sort=3d&page=22

 

 

I guess you are correct and Google is complaining of duplicate tags rather than duplicate content

The original ht_canonical.php produces no canonical url for all these.

My changes now produce a canonical url of

 

<link rel="canonical" href="http://www.shop.co.uk/products_new.php?page=27" />

<link rel="canonical" href="http://www.shop.co.uk/products_new.php?page=29" />

<link rel="canonical" href="http://www.shop.co.uk/products_new.php?page=23" />

<link rel="canonical" href="http://www.shop.co.uk/products_new.php?page=22" />

 

I am also seeing Duplicate content from These

 

/index.php?cPath=15

/index.php?cPath=1_15

 

ht_canonical.php currently produces canonical urls of

 

<link rel="canonical" href="http://www.shop.co.uk/index.php?cPath=15" />

<link rel="canonical" href="http://www.shop.co.uk/index.php?cPath=1_15" />

 

Here, I think Google is correct and this really is duplicate content

 

The next update to the add-on will address this.

 

Regards

 

Ken

Link to comment
Share on other sites

Duplicate content for pages that are the same except for the page number, like products_new.php?page=27 and products_new.php?page=29, is normal and not fixable, in my opinion. There would have to be some way to control the title and tags for any possible number of pages. The easy way would be to add the page number to the title and tags but that would not help with SEO so it would be a useless change. And even if the text for those could be easily controlled, what would the additional text be for the other pages? So this sort of warning should just be ignored.

 

You may also see this for product and product review pages. In that case, at least with Header Tags SEO, I recommend adding "Review for " to the product review title and tags. That will take care of those warning and be more accurate and helpful for SEO.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 9 months later...

Hello

 

I think i might have found an issue with this file, or least in my install

 

I have Osc 2.3.4BS with SEL reloaded and V2 of the HT_canonical file for new_products

 

The Canonical on page 2 or more of a mutlpage category lists the URL as

 

mydomain/product_details-C-99999.html&page=2 - this produces a 404

 

it should be 

 

mydomain/product_details-C-99999.html?&page=2 - Please note the ? missing from the canonical

 

It does not do the same in new_products so i assume its a error in the file

 

regards

 

David

 

 

 

 

 

 

Just an update

 

I have tried to fix this, but i am not a coder just stumbling through, i have changed this line

 

if (tep_not_null($page)) {$page= '&' . $page;}

 

to

 

if (tep_not_null($page)) {$page= '?' . $page;}

 

seems to work, going to do another crawl to see if i can see anymore probems

David

Link to comment
Share on other sites

After a deeper crawl I can confirm that while that change does indeed making a working link it somehow breaks the purpose of the canonical and creates multiple duplicate tille's

 

 

Back to the drawing board

David

Link to comment
Share on other sites

The other very important point i would have thought would have happened is a canonical link for the index page, not sure if this is a bug in the core 2.3.4bs

 

as there are a few different titles

 

index.php

index.php?currency=

 

and so on

David

Link to comment
Share on other sites

Hi @@wHiTeHaT

 

Sorry if my explanation is not very good, i will try to explain again, it may be a osc 2.3.4bs bug, i do not enough to confirm that

 

I have 2.3.4bs gold edition with seo reloaded, the HT_canonical module with support for new_products, my website address is in my  profile

 

 

 

Here is a sample category page, with pagination on page 9

http://www.my website.com/acer-laptop-battery-c-113_249_1738.html?page=9&sort=2a&language=en

 

This has a canonical link of

http://www.my website.com/acer-laptop-battery-c-113_249_1738.html&page=9

 

this causes a 404 as there is no such page the way the canonical link is written,

 

ie
.html&page=number - does not work

 

, the link is broken (thousands on my site), i tried to fix it as per my previous post but this broke the canonical link causing loads of duplicate titles instead so put it back

 

 

also there is no canonical link for Index.php

so it picks up as dupicate title things like

/index.php?currency=EUR

/index.php?currency=GBP

/index.php

/

 

 

also 

there is no Canonical for info pages like

contact _us.php

privacy.php

so these all have duplicate titles and description same as Index.php

 

I hope that explains it better

 

Thank you

 

David

David

Link to comment
Share on other sites

Hi

 

Do you mean that to support the HT_canonical module there should also be a rewrite method in .htaccess (do not remember seeing anything about that anywhere)

 

I am using Ultimate SEO URLS 2.2d, do you think that has something to do with it

 

 

what about the fact there is not a canonical for  index.php, contact.us and all the other information pages, is that related, or is that by design and another module of some sort needs to be uploaded to control these

 

Thank you

 

david

David

Link to comment
Share on other sites

The original ht_ i have here covers index.php :

      if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO) {
        $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id'], 'NONSSL', false) . '" />' . "\n", $this->group);
      } elseif (basename($PHP_SELF) == FILENAME_DEFAULT) {
        if (isset($cPath) && tep_not_null($cPath)) {
          $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL', false) . '" />' . "\n", $this->group);
        } elseif (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
          $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . (int)$HTTP_GET_VARS['manufacturers_id'], 'NONSSL', false) . '" />' . "\n", $this->group);
        }
      }
Link to comment
Share on other sites

This is the one I am using as posted for this thread, thank you

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2013 osCommerce

  Released under the GNU General Public License
*/

  class ht_canonical {
    var $code = 'ht_canonical';
    var $group = 'header_tags';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function ht_canonical() {
      $this->title = MODULE_HEADER_TAGS_CANONICAL_TITLE;
      $this->description = MODULE_HEADER_TAGS_CANONICAL_DESCRIPTION;

      if ( defined('MODULE_HEADER_TAGS_CANONICAL_STATUS') ) {
        $this->sort_order = MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER;
        $this->enabled = (MODULE_HEADER_TAGS_CANONICAL_STATUS == 'True');
      }
    }

    function execute() {
      global $PHP_SELF, $HTTP_GET_VARS, $cPath, $oscTemplate;

if (isset($_GET['page'])){$pageno= $_GET['page'];}
if ($pageno > 1) {
$page='page='. $pageno; }
else {$page='';}

		if (basename($PHP_SELF) == FILENAME_PRODUCTS_NEW) {
        $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_PRODUCTS_NEW, $page , 'NONSSL', false) . '" />' . "\n", $this->group);
		}	  
	  
		if (basename($PHP_SELF) == FILENAME_SPECIALS) {
        $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_SPECIALS, $page , 'NONSSL', false) . '" />' . "\n", $this->group);
		}
		
if (tep_not_null($page)) {$page= '&' . $page;}	

      if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO) {
        $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id'], 'NONSSL', false) . '" />' . "\n", $this->group);
      } elseif (basename($PHP_SELF) == FILENAME_DEFAULT) {
        if (isset($cPath) && tep_not_null($cPath)) {
          $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL', false) . $page . '" />' . "\n", $this->group);
        } elseif (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
          $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . (int)$HTTP_GET_VARS['manufacturers_id'], 'NONSSL', false) . $page.'" />' . "\n", $this->group);
        }
      }
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_HEADER_TAGS_CANONICAL_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Canonical Module', 'MODULE_HEADER_TAGS_CANONICAL_STATUS', 'True', 'Do you want to enable the Canonical module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_HEADER_TAGS_CANONICAL_STATUS', 'MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER');
    }
  }
?>

David

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...