How To Quickly Add The Canonical Link To Your WordPress Blog

Published on July 7, 2011 by      Print

I was recently working on a site for a client. He is on shared hosting and for some reason the typical .htaccess would not redirect the entire site to the www version of the site. This is problematic for SEO purposes, as you probably already know, because essentially you have two pages on the same Website splitting authority and competing for the same rankings.

Since I did not have access to the server configuration, my only option was to add Google’s “rel=canonical” meta information to the head section of the site. All in One SEO already accomplishes this task, however there was a conflict with another plugin that was preventing All in One SEO from working.

So, to get the desired effect, this is the snippet of code I placed in the header.php file right before the closing </head> element.

<link rel="canonical" href="<?php the_permalink(); ?>"/>

The permalink function will use the preferred website subdomain (www) or no subdomain (non www) based on what the WordPress owner has specified during setup and can be changed through the Settings -> General admin panel by editing the Site Address URL field to your preferred version.

Filed under: Wordpress and Tagged:

Did You Enjoy This Article?

Get FREE Updates, Enter Your Email Address:

Delivered by FeedBurner



6 Comments !

  1. BlogGirl says:


    hi thanks for the steps! I’m looking for this canonical links.

  2. toii says:


    Wow come-on and post more blogs on canonical links a lot of people have problems with this and love to read more information on the subject.

  3. mobile coupons says:


    I have recently learned about just this very thing. Canonical URLs send link juice to more than one page, even though they have the same content. Thanks for reinforcing this point to us all. The all in one SEO plugin is the best way to control your SEO tags on your WP blog.

  4. SEO Vietnam says:


    Thanks for great tip. I’ve looked for this method for a long time.

  5. rankONE says:


    Hi Jason,

    Does this work for https vs http, I have a client who is on a shared ssl that he has no control over, Google is picking up the https pages on the site and when they go there, they are seeing an untrusted website, I am trying to remove the https pages from being indexed but as it is a wordpress site, I am struggling to find a solution online.

    I have contact the host and told them to disable it, but they said they will not do that. So somehow while following every page on the website, i want to remove the duplicates of https because they are an information website and an ssl on their site would not make sense.

    Look forward to the response, hopefully you can help.

  6. Jack Sam White says:


    Yeah, it always works in WordPress, that is why we call wordpress most SEO friendly and easy to customize CMS in opensource world.


Leave a Reply

Asterisk (*) marked fields are required

Switch to our mobile site