Post by bkrenzin » Fri Aug 20, 2010 4:24 am

Has anyone created a solution for the lack of caonical urls on every page?

Opencart is such a great platform......but this seems to be an area that is lacking.

I have read all of the forum posts......so please do not bash me for not looking.

Also......I know that there are several here that do not believe that duplicate content is an issue. So if you are in that camp....please do not bash me for that either.

If anyone has created a global solution.....please advise.

I would like to get this totally corrected prior to the beginning of my link building campaign.

And if you are not a believer in that.....please do not bash me either.

Regards,

Brian

Gun Dog Supplies Discount Pet Supplies
iGunDog Kennel Supplies


New member

Posts

Joined
Wed Aug 18, 2010 10:20 pm

Post by Xsecrets » Fri Aug 20, 2010 6:08 am

no there have been no fully founded complete posted solutions, which you probably already know from your searching.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by SteveSherry » Fri Aug 20, 2010 6:24 am

Brian,
No bashing from me.
I believe that if you do not have full control over the incoming links or have many different variations of a page url, then canonical urls are the way to go (so says Matt Cutts @ google)

When it comes to canonical it is just a guide, (again as Matt Cutts says) Google can and will use another url if it views it to be better to the user.


I believe that I saw something on the roadmap that said is was due to be included in 1.5.0??? may be wrong though.

My Website ¦ Summer Madness Special Offer ¦


Active Member

Posts

Joined
Thu Apr 08, 2010 7:47 am
Location - Wirral, UK

Post by borys » Fri Dec 17, 2010 3:37 am

I came across similar problem... well, this might help:

I wanted to have canonical URLs in the HTML code of all category pages... and I did this:

1) I took several lines from catalog/controller/product/product.php (those lines are responsible for adding canonical URL on product page I think)

Code: Select all

	$this->document->links = array();
	
	$this->document->links[] = array(
		'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $this->request->get['product_id']),
		'rel'  => 'canonical'
	);
2) I put this code into catalog/controller/product/category.php (line 54) and modified it so it looks like the code below:

Code: Select all

	$this->document->links = array();
	
	$this->document->links[] = array(
		'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path']),
		'rel'  => 'canonical'
	);
...it works on my site ;)

website: 23webdesign
projects: RC cars, víno


Newbie

Posts

Joined
Fri Dec 17, 2010 3:15 am
Location - Czech Republic

Post by JAY6390 » Fri Dec 17, 2010 3:54 am

Well it does and it doesn't. You're saying the path should be the same as the path given in the request. This is fine for a single level category structure, but if you have subcategories you are going to be facing the same problem. Here's the solution

Code: Select all

$cat_paths = explode('_', $this->request->get['path']);
$current_cat = array_pop($cat_paths);

   $this->document->links[] = array(
      'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $current_cat),
      'rel'  => 'canonical'
   ); 

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Daniel » Fri Dec 17, 2010 7:42 am

if sonme could explain to me what needs doing i might be willing to add it into 1.5.0.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Xsecrets » Fri Dec 17, 2010 7:51 am

well the only way I can see that it would work 100% of the time for products is to do something like

Code: Select all

<link rel="canonical" href="http://www.example.com/index.php?route=product/product&product_id=28" />
of course running the url through the new url class so it gets rewritten. that way no matter how you get to the product page it always has the same canonical link.

I suppose you could do the same for category pages and leave off the sort so that the cononical link is always the same.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Chones » Fri Dec 17, 2010 8:05 am

As far as I'm concerned OpenCart works perfectly in respect to canonical URLs. Daniel, I don't think you have to do anything.

Canonical URLs only need to be used when the same page shows up via different URLs. That is not a problem with categories, sub-categories or manufacturer pages unless you've done some strange mods to your site.

The only place it was ever a problem was product pages, and Daniel has fixed that, perfectly.

I do SEO for a living (well, some of it). There is nothing wrong with OpenCart's canonical URLs. It's pretty much perfect. Stop worrying and finding fault where there is none.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by JAY6390 » Fri Dec 17, 2010 8:07 am

The method I put above literally just uses the pure url to the category, not all of the path to it, therefore no matter how you get to it it will always have the same URL
I don't think adding the sort order will be of any benefit to be honest. It's not really a crucial change in my opinion, but wouldn't hurt either

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Chones » Fri Dec 17, 2010 8:19 am

Honestly, unless you can reach the same page via different URLs there is no reason to have a canonical URL.

Anyway, I hardly care anymore, the search engines are pretty good at deciding what the canonical URL is. Matt Cutts said so himself. You should stop worrying about canonical URLs and get your on-page optimisation sorted - use Titles and Headings that include keywords and key phrases - that's the key to getting to the top of the results.

Stop worrying about canonical URLs - the only real problem OpenCart had was products in multiple categories. Daniel has fixed that.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by JAY6390 » Fri Dec 17, 2010 8:26 am

Well you can reach the same page with different urls, hence the need
For example if your category is "notebooks" under the category of computers then you can access the category either via
/notebooks/
or
/computers/notebooks/
so therefore just taking the last chunk of the path (the current category id) you can always assure it's the same canonical regardless of how you got there

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Chones » Fri Dec 17, 2010 8:33 am

Hi Jay. Yeah, I agree, you can do that. But is anyone (or any spider) ever going to do that? Humans and spiders follow trails. They will always end up at /computers/notebooks/. How would they ever end up at /notebooks/?

It is never going to happen, so stop worrying about it.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by JAY6390 » Fri Dec 17, 2010 8:51 am

You're running off the premise that everyone's cart is standard. They're not all the same. People have mods with things like all categories a product comes unde, these don't always have full paths of a category since it involves a lot more work to get back to the root category and make the full url. Also, categories get moved about from time to time, sometimes you need to move it from one to another, or expand into further subcategories. In this instance the path changes. That said, the canonical should still work regardless, and if google has the old one then it's clearly wrong. Having a permanent one no matter what seems to make more sense to me. It seems naive to assume it will never happen

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Chones » Fri Dec 17, 2010 9:05 am

No, I don't think I am. As far as all the categories a product comes under, Daniel has already fixed that with the current canonical URLs. It's a beautiful solution and actually improves SEO. Instead of http://www.yoursite.com/category/product, he's made the canonical URL http://www.yoursite.com/product. Page rank dilutes at every stage of the URL, so Daniel's solution saves Page rank.

I can see why products would appear in different categories or sub-categories. I really can't see why you would move a sub-category from one category to another. Categories and sub-categories aren't tangible. They are only organisational structures. You can put a product in several categories or sub-categories, but what is a sub-category? Would I want to move my /notebooks/ sub-category from /computers/ to /womens-dresses/? I'm not being naive - I just think you are making a problem where one doesn't exist.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by JAY6390 » Fri Dec 17, 2010 9:26 am

The womens-dresses idea is ridiculous, and you just seem to be being pedantic with it. No you don't move notebooks to womens dresses and to suggest so is just childish

Classic examle for you:
What if you have a store that sells just certain categories of clothing to begin with (t-shirts, shorts, jeans, etc etc), then branches out to sell other items like toys and electrical items, you would want to put them all in categories that are neatly arranged and move all of your clothing categories into a category called clothing. Now ALL of the clothing categories have moved

Based on your post above you say that having a "diluted" link means it's worse for SEO, but you now want your category links to be as long as possible, even if it's 10 links deep? Surely from what you say it would be better to have it as I've posted above, with just /category-name/ rather than /path/to/category-name/ since it's less diluted

Also I would like to point out that I didn't make this problem where it doesn't exists, I just posted the solution to a potential problem with the code posted by borys. You just seem to want to argue about something rather trivial. I really don't care either way if it makes it into the OC 1.5.0 release, and you shouldn't either. You don't have to upgrade if you prefer the cart as it is

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Chones » Fri Dec 17, 2010 10:04 am

Firstly Jay, apologies if I came across as a bit abrupt and argumentative. I really didn't mean to. I just don't see that this is a problem at all - and I admit I did use hyperbole for effect with the womens-dresses example. Sorry it annoyed you. My bad :-\

It may not be the same for everbody, but I'm selling products, not categories. And a lot of my products show up on the first page of Google. I don't really care how the categories do in Google.

And that's my main point. OpenCart is great for getting your individual products high up in the SERPS as long as you optimise your product page well. No matter how you arrange your categories or sub-categories, your products will always have the same canonical URL. Move your products to a different category, or put them in mulitple categories - same canonical URL.

And routes to categories can be used positively for SEO, despite the loss of Page rank. I've got gifts on my site and they are split into sub-categories. So my URLs are /gifts/for-children/, /gifts/for-him/, /gifts/for-her/ etc. Do I want my pages indexed like that, or like /for-children/ etc.?

But I guess there will be people out there wanting to rank for a category such as "jeans" or "t-shirts". All I can say is good luck to them.

I think Daniel has sorted out the main problem that OpenCart (and almost every other CMS) has with duplicate content. And he's done a great job. If people want just /category-name/ then that's fine with me, I just don't think it's that important compared to well-optimised product pages.

Again, apologies.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by tjonnyc » Fri Jan 14, 2011 8:04 am

I wanted to have the "SEO Friendly URL's" for product pages assigned as Canonical URL's.

Here's what I did:

1.) In catalog/view/theme/MyTheme/template/product/categorymail.tpl (your exact "category template" file may vary - our site has been customized),

I changed

Code: Select all

if ($products[$i]['subcategory'] == $width_category['subcategory_id']) { ?>
    <td>
        <a href="<?php echo $products[$i]['href']; ?>">
            <img src="<?php echo $products[$i]['thumb']; ?>" title="<?php echo $products[$i]['name']; ?>" alt="<?php echo $products[$i]['name']; ?>" />
            <br />
            <?php echo $products[$i]['name']; ?>
        </a>
to

Code: Select all

if ($products[$i]['subcategory'] == $width_category['subcategory_id']) { ?>
    <td>
        <a [b]rel="canonical"[/b] href="<?php echo $products[$i]['href']; ?>">
            <img src="<?php echo $products[$i]['thumb']; ?>" title="<?php echo $products[$i]['name']; ?>" alt="<?php echo $products[$i]['name']; ?>" />
            <br />
            <?php echo $products[$i]['name']; ?>
        </a>
As a result, now all the links to the product pages, displayed in the category pages, have the rel="canonical" in them.

Yay.

Now, 2 questions for the experts in the audience:

1.) Where else can these non-canonical URL's appear? I.e. is there any other way that Google can "detect" the ugly "product_ID" links?

2.) Can you think of any reason that this might hurt my SEO efforts?

Active Member

Posts

Joined
Tue Dec 21, 2010 5:05 am

Post by tjonnyc » Fri Jan 14, 2011 8:07 am

P.S. I didn't realize the "bold" tags would not work inside the "code" block.

<a rel="canonical" href="<?php echo $products[$i]['href']; ?>">

is what I meant :)

Active Member

Posts

Joined
Tue Dec 21, 2010 5:05 am

Post by Chones » Fri Jan 14, 2011 8:14 am

rel=canonical does not go in your links, it goes in the meta data of the product page - and OpenCart has this covered already.

I'm sorry, but you are doing work for no reason on a misunderstanding of how rel=canonical works.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by ifyouseek » Sat Oct 01, 2011 6:46 pm

to add canonical link to all category pages in 1.5.* make the following change:

open file - catalog/controller/product/category.php and find following line of code

Code: Select all

			$this->document->setKeywords($category_info['meta_keyword']);
after add -

Code: Select all

			$this->document->addLink($this->url->link('product/category', 'path=' . $path_id), 'canonical');
That's it... This will make your canonical link look like this - example.com/seo-keyword It ignores all subcategories similar to canonical link on product page

Active Member

Posts

Joined
Thu May 06, 2010 4:40 pm
Who is online

Users browsing this forum: Ahrefs [Bot], barnettgs and 121 guests