The new talk of the SEO world is ‘Canonical URL‘. What is canonical URL? This is the definition given in Google’s Webmaster Central Blog…
a format that allows you to publicly specify your preferred version of a URL. If your site has identical or vastly similar content that’s accessible through multiple URLs, this format provides you with more control over the URL returned in search results. It also helps to make sure that properties such as link popularity are consolidated to your preferred version.
Emphasis mine
It is very easy to specify the canonical URL of a page – all you have to do is add this line in the head section…
<link rel="canonical" href="http://binnyva.com/" />
The purpose of this tag is to prevent the problem of duplicate content.
The best thing about this tag is that all three major search engines(Google, Yahoo and MS Live) support this initiative.
WordPress
If you are on wordpress, this tag can be integrated into your theme easily. There is a plugin to do the job for you – but you don’t need a plugin to do something as simple as this.
header.php
Go to the theme folder in wordpress(wp-content/themes/<theme_name>) and open the file header.php
in your favorite editor. Now find the line…
</head>
and add the following code before that line…
<?php if ( is_singular() ) { ?>
<link rel="canonical" href="<?php the_permalink(); ?>" />
<?php } ?>
Now, it should look something like this…
<?php if ( is_singular() ) { ?>
<link rel="canonical" href="<?php the_permalink(); ?>" />
<?php } ?>
</head>
That’s it – you are done! Save the file and upload it to your server.
This fix will add the canonical URL tag to all the posts and pages of your blog. If you want to see a blog that have implemented this fix, take a look at the source of this page.
i think your understanding of where to place the canonical URL is wrong. You need to place them on the duplicate pages and not on the single posts. Read over google’s blog post again.
@Rajesh
It will be placed on the duplicate URLs as well – for eg, this page is a duplicate of the current page. The canonical URL link will point to the right URL in that page.
This fix also places the canonical link in the correct page as well – this is valid. The official example page – Star wars wikia does this too.
Yes, it should be placed on the duplicates but i am not sure about whether it is ok to place it on the original as well… but as you say, the example does it on both…
hmm , thanks for the info .. I actually need to learn this .. I am really bad with SEO π
I tried to take a look at Gizmodo.com ( a giant tech blog) and I can see they are placing the canonical URL link everywhere, even in their search page and tag archives. Anyone have any idea? If the big blog boy can do so, I guess we the small guy can follow too…
Try this Canonicals WordPress Plugin.
watched Matt for 20 minutes on this stuff π now I understand how important it is π need to give it a try .. I think I will use the plugin, since I usually change the theme a lot
You are right, we donβt need a plugin to do something as simple as this.
A canonical tag is given to the duplicate pages to say the search engine that the original source point to the location given in the link tag. It doesn’t make sense to me adding to all the pages unless it is duplicate. You can hard code this to the pages, better use a plugin for wp. I have written a post on this
Great Blog. I am working for SEO campaign of my site and found this blog which is quite a informative….thanks guys
Nice. One problem for me though, it does not seem to place the rel=”canonical” link to the home page. Any work-around or is this not a concern?
I like the idea of all of this, and I have no problem copying and pasting the code you provide. If I do a WordPress Upgrade or a Theme version upgrade, will I have to recode this?
Thanks!
Yeah – you’ll have to do that. If you change themes often, I suggest you go for the plugin.
it solved my problem on my wordpress blog, when severel NewsFeeds (NyhedsLinks) provide the same story/permalink… thanks !
*it DOES NOT solve my problem with my blog and newsfeeds, i meant..sorry for english
Hi,
Excellent post, right to the point. I linked your post from my blog: http://www.web-design-talk.co.uk/164/prevent-duplicate-content-using-the-canonical-url-tag/
Also, it’s worth noting you could use the all in one seo plugin for wordpress, as that generates canocial tags for all your posts.
Thanks
Really dumb question, sorry. I decided to stop using plugins for WordPress and do the SEO implementations as best I can myself with php, etc.
If I use THIS canonical url fix, will this cause issues with the canonical url’s that WordPress already has built in??
I know that all-in-one-seo plugin overrides WordPresses canonical url fix and then they use their own, correct? So, would I have to disable WordPress’s in the head and then use this head?
I didn’t tried this solution because I didn’t know about the canonical metatag. Interesting concept, hope to work. I had this problem with Avarcade script, Google indexed 2 pages with the same content for every page, seo friendly version and the non-seo friendly version.
Why is some people worried about having the canonical url on the single page?
If it’s on the single page it’s pointing to itself, so it’s all good. π
I think this is not working now. I tried this with my blog but seems its not working properly. Please check from your side.
Hi,
You said that the code you mention will “add the canonical URL tag to all the posts and pages of your blog”.
What if i want to make any single post of my choice to insert “canonical”. How can i do that?
Thanks.
Thank you for this nice information. Can We use Canonical tag for WP tags to avoid duplicate content?