Google and the Canonical Link Rel

By  on  

Google has introduced a link tag rel value of canonical which is used for defining the value of the page that Google should use. Why? Lets say you have an eCommerce site and one of the product URLs is:

http://yoursite.com/product.php?p=david+walsh+blog+book

Imagine now that you can make a slight customization to the product that changes the URL to:

http://yoursite.com/product.php?p=david+walsh+blog+book&color=red

Uh oh -- Google sees duplicate content! The code shows essentially the same page so Google thinks you're pulling gangsta stuff. Now you can tell Google what URL to use for the current page to avoid duplicate content penalization.

The XHTML

<link rel="canonical" href="http://yoursite.com/product.php?p=david+walsh+blog+book" />

Don't let your website get penalized by Google; use this link/rel tag combination for your highly variable pages.

Recent Features

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

  • By
    From Webcam to Animated GIF: the Secret Behind chat.meatspac.es!

    My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...

Incredible Demos

  • By
    CSS Filters

    CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...

  • By
    QuickBoxes for Dojo

    Adding to my mental portfolio is important to me. First came MooTools, then jQuery, and now Dojo. I speak often with Peter Higgins of Dojo fame and decided it was time to step into his world. I chose a simple but useful plugin...

Discussion

  1. Note that the All-in-one SEO WP plugin does this for you. Good to know should you bloggers be worried.

  2. I think the article could have given a bit more info on canonical urls…

  3. @Adriaan: Thank you for your comment. I could have but my fear is spending a ton of time on an explanation when 99% of people would prefer a brief explanation with a sample problem and solution like I provided. I appreciate your honesty!

  4. OK, I had to go to Google to find out where in the document this LINK goes… But this is good info, thanks for the the tip. Google implies that some other search engines look at this too.

  5. emceha

    time to google for more about canonical ;)

  6. Cool information!
    Liked the posts about firefox extensions too, really useful for beginners on that world.

    ps: you forgot to close the link tag.

  7. Add this code to the section of the page.

    < head >
    < title > Davidd Walsh Blog Book< /title >
    < link rel=”canonical” href=”http://yoursite.com/product.php?p=david+walsh+blog+book” />
    < /head >

    @Fabio, No missing < /a > tag as its a < link .. >

  8. Good I want to implement it first and have post this tips. Thanks

  9. great post is there any problem if i use rel tag for all of my links

  10. David,
    Thanks for the tip about rel canonical.

    Peter

  11. You can find more info here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394
    Thanks for the article.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!