Post by radact » Thu Oct 17, 2024 6:53 am

Is there a way to stop Google crawls from creating so many canonical errors when indexing my site?
For a site that has <1500 pages, I get over 150,000 errors!

eg:

Code: Select all

https://www.anotherworld.com.au/shop/sound-and-audio?sort=rating&order=DESC&page=7&limit=50
https://www.anotherworld.com.au/shop/accessories-and-smart-watches?sort=rating&order=DESC&page=43
https://www.anotherworld.com.au/shop/software?page={page}
https://www.anotherworld.com.au/shop/merchandise?sort=pd.name&order=DESC&page=11&limit=25
https://www.anotherworld.com.au/shop/fan-splitter-cables?page=2&limit=20
As you can see, I've created SEO friendly URL's for products and categories, and properly formatted sitemaps, with various extensions that I've been able to find, but all that junk after the "?" is causing all these errors that I don't know where it's coming from or where Google is picking that up from! How do I make it just stick to the product names and categories and ignore all the extra data?

Thanks in advance!
OC 2.3.0.2

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by ADD Creative » Thu Oct 17, 2024 5:23 pm

There was a bug in 2.3.0.2 where some of the canonical tags were missing if the category URL had page in. https://github.com/opencart/opencart/issues/4637

In catalog/controller/product/category.php find.

Code: Select all

if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], true), 'canonical');
} elseif ($page == 2) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], true), 'prev');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1), true), 'prev');
}
if ($limit && ceil($product_total / $limit) > $page) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');
}
And replace with.

Code: Select all

if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} elseif ($page == 2) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'prev');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1)), 'prev');
}

if ($limit && ceil($product_total / $limit) > $page) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1)), 'next');
}

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by radact » Thu Oct 17, 2024 7:29 pm

So make a new XLM file in the vqmod/xml folder like this?:

Code: Select all

<modification>
   <id>Header Logos</id>
   <version>1.1</version>
   <vqmver>2.6.1</vqmver>
   <author></author>
   <file name="catalog/controller/product/category.php">

      <operation error="log">
         <search position="replace">
		<![CDATA[
if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], true), 'canonical');
} elseif ($page == 2) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], true), 'prev');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1), true), 'prev');
}
if ($limit && ceil($product_total / $limit) > $page) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');
}
		]]>
         </search>
         <add>
		<![CDATA[
if ($page == 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} elseif ($page == 2) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'prev');
} else {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1)), 'prev');
}

if ($limit && ceil($product_total / $limit) > $page) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1)), 'next');
} 
       ]]>
         </add>
      </operation>

   </file>
</modification>\

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by ADD Creative » Fri Oct 18, 2024 12:24 am

You can only replace single lines with vQmod. In which case, if you don't want to fix the core files, then you are probably better adding the following with a vQmod.

Code: Select all

if ($page > 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
}

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by radact » Fri Oct 18, 2024 6:02 am

Sorry, I'm confused now.
Can you please provide the vqmod code exactly so I can just cut n'paste it?

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by ADD Creative » Fri Oct 18, 2024 6:50 pm

Change the file section in your vQmod to.

Code: Select all

<file name="catalog/controller/product/category.php">
	 <operation error="log">
	 	<search position="before"><![CDATA[
if ($page == 1) {
		]]></search>
		 <add><![CDATA[
if ($page > 1) {
	$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), 'canonical');
}
		]]></add>
	</operation>
 </file>

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by radact » Sat Oct 19, 2024 7:47 am

Thanks, let's see if it starts to make any improvement after Google does another crawl.

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by radact » Tue Nov 26, 2024 10:45 am

Is that all that is needed? Just that Page 1 reference? or the longer code you posted previously?

Some time has passed, but it doesn't seem to have made a difference to number of errors.

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by by mona » Tue Nov 26, 2024 12:51 pm

radact wrote:
Thu Oct 17, 2024 6:53 am
Is there a way to stop Google crawls from creating so many canonical errors when indexing my site?
I get over 150,000 errors!

eg:

Code: Select all

https://www.anotherworld.com.au/shop/sound-and-audio?sort=rating&order=DESC&page=7&limit=50
https://www.anotherworld.com.au/shop/accessories-and-smart-watches?sort=rating&order=DESC&page=43
https://www.anotherworld.com.au/shop/software?page={page}
https://www.anotherworld.com.au/shop/merchandise?sort=pd.name&order=DESC&page=11&limit=25
https://www.anotherworld.com.au/shop/fan-splitter-cables?page=2&limit=20
You say 150,000 canonical errors and paste 5. The 5 you have posted are all dealt with in robots.txt

Code: Select all

Disallow: /*?page=$
Disallow: /*&page=$
Disallow: /*?sort=
Disallow: /*&sort=
Disallow: /*?order=
Disallow: /*&order=
Disallow: /*?limit=
Disallow: /*&limit=

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by radact » Tue Nov 26, 2024 1:30 pm

Thanks Mona, appreciate that advice... I'll pop that in the robots.txt file and see what happens with the google indexes.
I'll update here once I've given it some time to reindex the site.

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by ADD Creative » Tue Nov 26, 2024 8:38 pm

radact wrote:
Tue Nov 26, 2024 10:45 am
Is that all that is needed? Just that Page 1 reference? or the longer code you posted previously?

Some time has passed, but it doesn't seem to have made a difference to number of errors.
Google can take months to re-crawl all the pages. You could inspect the URLs in Search Console and then Test Live URL. If all looks OK, you could then Validate Fix.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 34 guests