Canonical tag for SEO

Google, Yahoo and Microsoft are now supporting the canonical meta tag as the standard for identifying the actual source of your content: the real URL that you want to recieve page rank for your key terms.

Many sites have the same content show up with different URLs due to search features, dynamically generated URLS, tags, etc. Google, Yahoo and other search engines have been knocking your sites for having duplicate content as if you were spamming your terms. In other words, having multiple URLs pointing to the same content has been hurting your page rank and your site.

Now you have a way to make sure that your multiple content helps you instead of hurts you.

Implementing the CANONICAL meta tag

  1. Pick one URL for your page – “the pretty, preferred or canonical URL” (to quote Matt Cutts). For example, this page’s main, or canonical, URL is, though you may find it thru or, or simply
  2. Figure out how to include your page’s main URL in pages that are dynamically generated. For example, I need to figure out how to include my primary URL – in the web page showing this content no matter which URL from the bullet point above is shown.
  3. Once you know how to get the URL you picked in step 1 into your possible other pages feeding the content from your main URL, place the canonical link tag inside the tag with the main content’s URL. For this example, I would place: <link rel=”canonical” href=”” /> in my header.

The syntax is similar to the stylesheet link tag:

<link rel=”canonical” href=”” />

The canonical tag is ONLY for webpages in the same domain. So, pointing to or is fine. However, I can’t point to if I were to have that URL as an addon domain on this server.

Now I just have to figure out how to do step 2 so I can create canonical links for this blog.

Added Notes:

Lori basically figured it out for us: (copied from Thanks!

Add canonical link tag to head

<?php if ( is_single() || is_page() ) { ?>
<link  rel="canonical" href="<?php the_permalink(); ?>" />
<?php } ?>

Occurs to me now that you’d have to hardcode main url, then get the slug and other url info dynamically:

<?php if ( is_single() || is_page() ) { ?>
<link rel="canonical" href="<?php echo the_time('Y'); ?>/<?php echo the_time('m'); ?>/<?php echo the_time('d'); ?>/<?php echo $post->post_name; ?>" />
<?php } ?>

There is probably a prettier and/or more efficient way to do that, but can’t think of one at the moment.

This entry was posted in Best Practices, SEO, Web Development. Bookmark the permalink.

7 Responses to Canonical tag for SEO

  1. Lori says:

    That’s very cool. Thanks for the info. Maybe I will finally change my url/site name 🙂

    How about this in the “ for the blog links?

    `<link rel=”canonical” href=”” />`

    Only had time for a quick test, but it seemed to do the trick.

  2. Lori says:

    oops. tags were stripped. Will try again…

    How about this in the head for the blog links?

    <link rel=”canonical” href=”” />

  3. Florian says:

    Very interesting, although I think some people with affiliate URLs ranking in the SERPs won’t be happy about the possible loss.

  4. Diamara says:

    Nice explanation some examples of why this is important and a link to a Firefox extension to help developers can be found here:

  5. Trey Brister says:

    Hi, since canonical domain names will not work cross domain, here is a good solution for ASP users.

    PS: I linked to this URL in the post. Can I get a reciprocal link?

  6. I was able to use the canonical tag to fix a tricky problem where Google wasn’t honoring the 301 redirect I had in place directing search engine spiders from the version of my site to the version. It was still indexing my main page without the www while it indexed inner pages just fine with the www. My host recommended trying the canonical tag because we were pretty much out of other solutions.