We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Canonical Link Tags (SEO)

Development and Programming

Dom Stubbs's avatar
Dom Stubbs
156 posts
16 years ago
Dom Stubbs's avatar Dom Stubbs

Earlier this month a new <link> tag parameter became available with the purpose of providing search engines with the definitive URL for pages. I have created a (hugely) basic plugin which will generate these tags for you, so long as your site’s URL structure is completely segment-based. 99.99% of EE sites will be.

To see why you should bother with this see Google’s documentation, Matt Cutts’ writeup and SEOmoz, which describes it as ‘The Most Important Advancement in SEO Practices Since Sitemaps’.

To implement the plugin just upload it and add {exp:canonical_tag} within your <head> tags.

Download the Canonical Link Tags plugin.

       
mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse

Hi!

Interesting plugin.

I put this on my templates… Quick question:

How is this different than just outputting the URL to the page you are on?

As far as I can see, the cononical link is the same as the URL in the location bar.

Why can’t google use that?

Thanks! Micky

       
mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse

I guess it seems like EE generates good links anyway… If it is not broke, why fix it?

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

You may want to read up on this issue, perhaps using the links provided int he first article, these are not regular links we are talking about.

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
16 years ago
Dom Stubbs's avatar Dom Stubbs
Hi! Interesting plugin. I put this on my templates… Quick question: How is this different than just outputting the URL to the page you are on? As far as I can see, the cononical link is the same as the URL in the location bar. Why can’t google use that? Thanks! Micky

EE does do a very good job of generating consistent links, but you can’t control every link to every page on your site and this is basically a simple means of telling search engines which one is correct.

For example, I can be pretty much certain that it would be possible to access a single page on your site via all of the following URLs:

  • http://www.example.com/seg1/seg2/
  • http://www.example.com/seg1/seg2
  • http://www.example.com/seg1/seg2/?sort=desc
  • http://example.com/seg1/seg2/
  • http://example.com/seg1/seg2
  • http://example.com/seg1/seg2/?S=e943201f992028bf52702755c58e85d8329221c1

What this plugin does is ensure that the correct address, in this case http://www.example.com/seg1/seg2/, is output as the canonical tag setting irrespective of which URL variation is accessed.

The links in my first post all do a much better job of describing it than me, however.

       
mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse
The links in my first post all do a much better job of describing it than me, however.

Hi!

I do not mean to sound like I dislike your plugin… I like it a lot.

All of the links you provided were very interesting to read/watch. The yahoo video definitely did a good job at describing the situation.

I guess I just could not think of a spot on my EE powered site where the URL was not already the canonical link… But I think your last post put that into perspective for me. 😊

Thanks for the clarification.

Nice work!

Cheers, Micky

       
mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse

Hi, still loving your plugin!

Just thought I would put in a feature request:

$this->return_data = '<link rel="canonical" href="' . $FNS->fetch_current_uri() . '" >';

It would be nice if the plugin allowed one to change the ” />” at the end… I personally use a non-XHTML dtd, and the ” />” breaks validation.

Thanks! Micky

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
16 years ago
Dom Stubbs's avatar Dom Stubbs

I imagine it’s simpler just to edit the line of code in the plugin itself. You’d simply change that line to

$this->return_data = '<link rel="canonical" href="' . $FNS->fetch_current_uri() . '">';
       
mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse

Hi Dom!

Thanks for the quick reply. 😊

I actually did edit that line… It was pretty easy.

Just thought I would post a feature request here. No biggy though. 😊

Thanks again for your plug!

Have a great day! Cheers, Micky

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.