1. I am using optimised page titles of the format "Product - Category - Site Name". The canonical URL is not in a category so the titles indexed become "Product - - Site Name". Not good for SEO or click-throughs.
2. The canonical URL pages do not have expanded navigation or breadcrumbs. This means that the internal linking which allows Google etc. to calculate the internal linking hierarchy of the site is non-existent: in effect, all pages are at the top-level, and the category/sub-category pages are very weakly cross-linked. Again, not good for SEO.
Is it possible to force the canonical URLs to be of the format http://www.sitename.com/category/sub-ca ... -name.html? I am using 1.5.1.1.
A happy OpenCart developer from Brighton.
Been thinking about making a module for this just didn't get around doing it.
Anyone else want this one so that i can give this a higher priority.
Regards Werner.
If you do that (add to multiple) then the product page will not know which categories to use for the canonical URL.
However, if you only add your products to one category (be that a main cat or subcat - but not both) then it is feasible to change the canonical URL to the structure you want.
To do so, edit: catalog/controller/product/product.php
Find
Code: Select all
$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
Code: Select all
if($this->model_catalog_product->getCategoryPath($this->request->get['product_id'])!='0'){
$this->document->addLink($this->url->link('product/product', 'path=' . $this->model_catalog_product->getCategoryPath($this->request->get['product_id']) . '&product_id=' . $this->request->get['product_id']), 'canonical');
}else{
$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
}
find
Code: Select all
}
?>
Code: Select all
public function getCategoryPath($product_id) {
$query = $this->db->query("SELECT COUNT(product_id) AS total, category_id as catid FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
if($query->row['total']==1){
$path = array();
$path[0] = $query->row['catid'];
$query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$path[0] . "'");
$parent = $query->row['pid'];
$p = 1;
while($parent>0){
$path[$p] = $parent;
$query = $this->db->query("SELECT parent_id AS pid FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$parent . "'");
$parent = $query->row['pid'];
$p++;
}
$path = array_reverse($path);
$fullpath = '';
foreach($path as $val){
$fullpath .= '_'.$val;
}
return ltrim($fullpath, '_');
}else{
return '0';
}
}
There's probably an easier way to do the above, but it was requested for one of my extensions and it works.
vqmod file if you want it:
A happy OpenCart developer from Brighton.
Presumably the DB schema would have to be modified to either store canonical url or default category in the product table or in a secondary table. Is there anyway around this? I don't particularly want to start messing with the DB schema since it is destined to break future upgrades.
The Veloz Group
Beverly Hills Chairs: The leaders in ergonomic seating
Custom Tobacco: Customized cigars for any occasion
I am also thinking about doing the same thing if no breadcrumbs are found, but not sure when I'll get around to that.
The Veloz Group
Beverly Hills Chairs: The leaders in ergonomic seating
Custom Tobacco: Customized cigars for any occasion
I am seeing the same thing as adi_555 -- doesn't seem to use canonical url for categories. Is this a bug? Categories can have multiple urls with SEO mod.adi_555 wrote:Hi ,
I am having a similar problem, there are duplicates reported by google on category meta description and title. but not for products.
Is there a way we can set this canonical thing ?
The Veloz Group
Beverly Hills Chairs: The leaders in ergonomic seating
Custom Tobacco: Customized cigars for any occasion
I am working on a extention for my customers the canonical tag was one of the things that was modified, i choose to fall back to the latest added category so ppl will not have problems with duplicate sort orders or forgot to set it all together.
The categories are added to the database with an auto increment function on the category id.
Regards Werner
I think daniel should respond on this as I can see alot of people have a similar issue.jordan wrote:I am seeing the same thing as adi_555 -- doesn't seem to use canonical url for categories. Is this a bug? Categories can have multiple urls with SEO mod.adi_555 wrote:Hi ,
I am having a similar problem, there are duplicates reported by google on category meta description and title. but not for products.
Is there a way we can set this canonical thing ?
Can you address why category pages don't have a canonical url? There are multiple routes to a given category page leading to duplicate pages. Wondering if there is a specific reason for this, or if it was just an oversite one us can patch it and submit a fix.
The Veloz Group
Beverly Hills Chairs: The leaders in ergonomic seating
Custom Tobacco: Customized cigars for any occasion
Products in several categories I can understand, a sub-category in several categories doesn't seem to make sense.
Just create a new sub-category in the other categories to fix the problem. That's why there's no need for canonical URLs for categories.
Unless I'm missing something.
Or is it just that Google is indexing your ?sort=, ?page= for your categories, if this is the case you just need to block access with a robots.txt file.
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
For ex category is (lenovo)Chones wrote:Could you explain how you are getting multiple routes to a given category?
Products in several categories I can understand, a sub-category in several categories doesn't seem to make sense.
Just create a new sub-category in the other categories to fix the problem. That's why there's no need for canonical URLs for categories.
Unless I'm missing something.
Or is it just that Google is indexing your ?sort=, ?page= for your categories, if this is the case you just need to block access with a robots.txt file.
/Lenovo/lenovo-s10
/Lenovo
/Lenovo?sort=pd.name&order=ASC
/Lenovo?sort=rating&order=ASC
/pc/Lenovo
/pc/Lenovo
I may be wrong but this looks like a product within that category:
/Lenovo/lenovo-s10
To get rid of the sort listings you need a robot.txt file in the root of your site - I recommend the robots.txt file includes the following for good SEO.
Code: Select all
User-agent: *
Disallow: /*?sort
Disallow: /*&sort
Disallow: /*?limit
Disallow: /*&limit
Disallow: /*?route=checkout
Disallow: /*?route=account
Disallow: /*?route=product/search
Disallow: /*&keyword
Disallow: /*?page=1
Allow: /
Hope that helps.
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
google can still get to lenovo if SEO url is enabled just buy www.xyz.com/lenovo , no matter what parent category it is in.Chones wrote:Okay, so it looks like you should only have the category indexed as:
/pc/Lenovo
I may be wrong but this looks like a product within that category:
/Lenovo/lenovo-s10
To get rid of the sort listings you need a robot.txt file in the root of your site - I recommend the robots.txt file includes the following for good SEO.
That leaves /Lenovo and /pc/Lenovo. There should be no way for a Google bot to get to /Lenovo without going via /pc so you may want to look at the links in your navigation that go to /Lenovo. Make sure they all include /pc/.Code: Select all
User-agent: * Disallow: /*?sort Disallow: /*&sort Disallow: /*?limit Disallow: /*&limit Disallow: /*?route=checkout Disallow: /*?route=account Disallow: /*?route=product/search Disallow: /*&keyword Disallow: /*?page=1 Allow: /
Hope that helps.
and seeing the above recommendation for robots file, you are also block search keywords, woudnt this affect the search listings????
And the robots.txt file doesn't block any keywords, it stops search engines indexing URLs like this:
/index.php?route=product/search&keyword=blue
That way the search engines can focus on your products and not a lot of useless URLs.
See here for more details: http://www.robotstxt.org/robotstxt.html
Trust me, I know what I'm doing
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
I don't like the longer URLs, I do want to keep the canonical on the product pages to the short and clean URL.
What I was thinking was to add a query to pull the categories the product is in, and have it populate in the breadcrumb and category, but keep the URL the same.
Anyone know what query to add here?
Thanks
I get this error:
[03-Dec-2011 20:10:59] PHP Fatal error: Call to a member function getCategoryPath() on a non-object in /catalog/controller/product/product.php on line 42
Here is the hacked code:
Code: Select all
if (isset($this->request->get['path'])) {
$path = '';
foreach (explode('_', $this->request->get['path']) as $path_id) {
if (!$path) {
$path = $path_id;
} else {
$path .= '_' . $path_id;
}
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) {
$this->data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('product/category', 'path=' . $path),
'separator' => $this->language->get('text_separator')
);
}
}
} else {
$path = '';
foreach (explode('_', $this->model_catalog_product->getCategoryPath($this->request->get['product_id'])) as $path_id) {
if (!$path) {
$path = $path_id;
} else {
$path .= '_' . $path_id;
}
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) {
$this->data['breadcrumbs'][] = array(
'text' => $category_info['name'],
'href' => $this->url->link('product/category', 'path=' . $path),
'separator' => $this->language->get('text_separator')
);
}
}
}
Add this before </modification> to the xml files above for a canonical url on category pages:jordan wrote:I am seeing the same thing as adi_555 -- doesn't seem to use canonical url for categories. Is this a bug? Categories can have multiple urls with SEO mod.adi_555 wrote:Hi ,
I am having a similar problem, there are duplicates reported by google on category meta description and title. but not for products.
Is there a way we can set this canonical thing ?
Code: Select all
<file name="catalog/controller/product/category.php">
<operation>
<search position="after"><![CDATA[
$this->document->setKeywords($category_info['meta_keyword']);
]]></search>
<add><![CDATA[
$this->document->addLink($this->url->link('product/category', 'path=' . $this->request->get['path']), 'canonical');
]]></add>
</operation>
</file>
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here
Users browsing this forum: No registered users and 14 guests