Community Forums

Canonical URL's

General support for technical problems with OpenCart v1.x

Canonical URL's

Postby bkrenzin » Thu Aug 19, 2010 3:24 pm

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
bkrenzin
 
Posts: 52
Joined: Wed Aug 18, 2010 9:20 am

Re: Canonical URL's

Postby Xsecrets » Thu Aug 19, 2010 5:08 pm

no there have been no fully founded complete posted solutions, which you probably already know from your searching.
Xsecrets
 
Posts: 5027
Joined: Sat Oct 24, 2009 2:51 pm
Location: FL US

Re: Canonical URL's

Postby SteveSherry » Thu Aug 19, 2010 5:24 pm

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.
SteveSherry
 
Posts: 583
Joined: Wed Apr 07, 2010 6:47 pm
Location: Wirral, UK

Re: Canonical URL's

Postby borys » Thu Dec 16, 2010 2:37 pm

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
borys
 
Posts: 2
Joined: Thu Dec 16, 2010 2:15 pm
Location: Czech Republic

Re: Canonical URL's

Postby JAY6390 » Thu Dec 16, 2010 2:54 pm

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'
   
); 
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4888
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Canonical URL's

Postby Daniel » Thu Dec 16, 2010 6:42 pm

if sonme could explain to me what needs doing i might be willing to add it into 1.5.0.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5310
Joined: Fri Nov 03, 2006 5:57 am

Re: Canonical URL's

Postby Xsecrets » Thu Dec 16, 2010 6:51 pm

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.
Xsecrets
 
Posts: 5027
Joined: Sat Oct 24, 2009 2:51 pm
Location: FL US

Re: Canonical URL's

Postby Chones » Thu Dec 16, 2010 7:05 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby JAY6390 » Thu Dec 16, 2010 7:07 pm

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
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4888
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Canonical URL's

Postby Chones » Thu Dec 16, 2010 7:19 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby JAY6390 » Thu Dec 16, 2010 7:26 pm

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
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4888
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Canonical URL's

Postby Chones » Thu Dec 16, 2010 7:33 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby JAY6390 » Thu Dec 16, 2010 7:51 pm

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
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4888
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Canonical URL's

Postby Chones » Thu Dec 16, 2010 8:05 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby JAY6390 » Thu Dec 16, 2010 8:26 pm

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
ImageImageImage

SEO MEGA KIT PLUS - Get your site ranking higher in the search engines
Better Product SEO URL's - Perfectly structured product links
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4888
Joined: Wed May 26, 2010 10:47 am
Location: United Kingdom

Re: Canonical URL's

Postby Chones » Thu Dec 16, 2010 9:04 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby tjonnyc » Thu Jan 13, 2011 7:04 pm

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?
tjonnyc
 
Posts: 102
Joined: Mon Dec 20, 2010 4:05 pm

Re: Canonical URL's

Postby tjonnyc » Thu Jan 13, 2011 7:07 pm

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 :)
tjonnyc
 
Posts: 102
Joined: Mon Dec 20, 2010 4:05 pm

Re: Canonical URL's

Postby Chones » Thu Jan 13, 2011 7:14 pm

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.
User avatar
Chones
 
Posts: 755
Joined: Wed Mar 24, 2010 8:07 am
Location: London

Re: Canonical URL's

Postby ifyouseek » Sat Oct 01, 2011 5:46 am

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
ifyouseek
 
Posts: 154
Joined: Thu May 06, 2010 3:40 am

Next

Return to General Support

Who is online

Users browsing this forum: Bing [Bot], colorama, Cue4cheap, improvedance, spdavis and 127 guests

Hosted by Arvixe Web Hosting