Where to find Malcolm Coles, reviews, and tips on how to do things I couldn’t do.

malcolm coles


Can you use rel = canonical to fix duplicate comment problems caused by comment pagination in wordpress? 3

Posted on February 15, 2009 by Malcolm Coles

If you turn on comment pagination in wordpress, you get duplicate content problems.

This means a posts' comments are split across several pages and URLs - the post at the top is the same on each URL but the comments are different. There is also a URL version - the /comment-page-1/ one - that is identical to the permalink. This is a problem even if you don't have enough comments for pagination to kick in.

This means you'll end up with people linking to different 'versions' of the post, diluting the SEO benefit of those links.

Rel = canonical

The major search engines have agreed a new tag - rel=canonical - so that you can tell them, if you have the same content across several URLs on your site, which is the 'real' one. They'll treat the different versions as if they were the real one - including the benefit of all the links to the other URLs.

It's designed to help sites whose URLs contain session IDs or, say, sort orders for tabular information. But can you use it to fix the problem of the same post with several URLs, each with different comments on?

Code to use rel=canonical

This is the code you'd add to your head section to make rel=canonical appear:

<?php if (is_single()) {
echo '<link rel="canonical" href="';
echo get_permalink();
echo '">';
} ?>

I'm sure with my customary inelegant PHP, this can be optimised.

Anyway, what do you think? Is this the solution to duplicate content caused by comment pagination?

Obviously, this case is slightly different to the use intended for rel=canonical, as the content isn't identical (as the comments are different) - apart from the /comment-page-1/ version, where it is identical.

More reading about comment pagination and duplicate content in wordpress

Try these sites:

More reading about rel = canonical

Try these sites:

You might also like
  1. Wordpress comment pagination & duplicate content
  2. Avoid duplicate content with paged comments in wordpress
  3. Adding page numbers: How to avoid duplicate titles and meta descriptions in pages 2 and higher of Wordpress category and tag pages
  4. Cross-domain rel=canonical now supported by Google
  5. 29 easy ways to fine tune your blog

You should follow me on Twitter.

3 Responses to “Can you use rel = canonical to fix duplicate comment problems caused by comment pagination in wordpress?”

  1. Peter Nichol says:

    Brilliant, thanks for commenting on my website, I like this article a lot.

    I'd heard of rel=canonical but have never really done any research into it.

    Thanks.
    -Peter

Leave a Reply

All comments are moderated. Comments that include URLs and which just say 'Nice post' or similar won't be published, but thanks for the sentiment.

Find more posts like this



↑ Top