The developers decided that in Opencart 3+ for SEO it would be very useful to add a link to the current page as canonical, even if it is a pagination page. This is an awful SEO solution, so you need to make some changes.
So, you need:
from <link href=”https://domain/path?page=2 ” rel=”canonical” />
delete ?page=2,
from <link href=”https://domain/path?page=3 ” rel=”canonical” />
delete ?page=3 etc.
I didn’t find any articles about this problem in Google, but there is a solution. Edit the
file/catalog/controller/product/category.php, look for a string 338 (the line number may be different) and instead of this:
if ($page == 1) {
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page=' . $page), 'canonical');
}
write this:
if ($page == 1) {
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
} else {
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id']), 'canonical');
$this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. $page), '');
}
After that, edit /catalog/view/theme/yourtemplate/template/common/header.twig and instead of this:
{% for link in links %}
<link href="{{ link.href }}" rel="{{ link.rel }}" />
{% endfor %}
write this:
{% for link in links %}
{% if link.rel %}
{% else %}
{% endif %}
{% endfor %}
Don’t forget to clean the cache in the admin panel.
WEBinP Your guide to resolving CMS optimization, Web Development and SEO problems