Paginated Comments without Sacrificing SEO? You Betcha!

WordPress 2.7 was a momentous release for many bloggers, especially those who place a lot of importance on comments and the conversation generated therein. Introduced in that version of WordPress were several important updates to the commenting system which, from a users’ point of view, has remained largely the same for years: threaded comments, reverse order comments, and paginated comments.

Unfortunately, the third feature — paginated comments — creates a nightmarish duplicate content possibility. What happens is that, as a page’s number of comments grows, a page accumulates an increasing number of pages at which it can be accessed. For example:


There is no upper limit to how many pages there can be, yet each page has the same primary content as the main page’s permalink; the only thing that differs are the comments themselves, which incidentally are far less important from a search engine optimization perspective. To make matters worse, the page’s primary permalink (the first item in the list above) is identical to the page as accessed at comment-page-1/, the second item in the list above. You’re killing me, WordPress!

I’ve heard much discussion as to what to do about this — duplicate content is rightfully frowned upon by respectable search engines. Often suggested is adding a “noindex” tag for robots on all comment-page-#/ page variants. I’ve suggested that on comment-page-# variants, only the post excerpt should be output so that the bulk of the content on the page does, in fact, change, and that only the canonical permalink will carry the full post’s content.

Here at the Rick Beckman archive, because I don’t use paged comments, I use this simple line in my .htaccess file which is designed to effectively nuke the comment-page-#/ crap from my URIs:

RedirectMatch permanent ^/(.+)/comment-page-[0-9]+/$1/

Note that the above redirect rule will only work if the Apache module mod_redirect is available. It’s also designed to work with my preferred style of permalinks (/%postname%/). YMMV.

However, leave it to the big G itself, Google, to come up with what looks like an even better solution: specifying a canonical address to consolidate multiple addresses which may be substantially similar.

From their announcement, it looks as though a canonical address allows “properties of the two URLs [to be] consolidated in our index and search results display [a site]’s intended version.”

So I wonder if this means that we can specify a canonical address for our posts so that all of the paged comments are considered consolidated into the one page? That’d be handy. Thankfully, it’s really easy to do!

Using most WordPress themes, you can drop this into your theme’s functions.php file:

function canonical_urls() {
	echo '<link rel="canonical" href="' . get_permalink() . '" />';
if (is_single() || is_page())
	add_action('wp_head', 'canonical_urls');

If you are using the world’s best WordPress theme (Thesis), you can add that code to your custom_functions.php file and never have to worry about it when upgrading your theme.

I’m unsure how well this method will work given that pages and pages of comments are a bit more diverse than the minor changes between pages in the examples given in Google’s announcement, but if it does work, it allows you to use paginated comments without sacrificing your search engine optimization, which by default WordPress totally fails to allow you to do. Or maybe they were just too busy taking pictures to realize what they’ve wrought upon us all.

6 thoughts on “Paginated Comments without Sacrificing SEO? You Betcha!”

  1. You would think so, but pay attention to any links from your admin panel — they all append the paged comments crap, and WordPress doesn’t strip it when you follow the links. While it may be unlikely that the paged comments should be an issue when the feature is actually disabled, the comments-page-1/ variant seems to always exist in WordPress’ opinion, and that absolutely sucks.

  2. @Rick

    Thanks for the clarification – your work with Thesis and WP is appreciated.

    BTW – Still can’t get the Compatibility Suite download to work ;)

  3. Yoast has a small plugin to fix those canonical links. I’ve already implemented it on all of the WordPress websites I can access. And I have a good feeling the next version of our beloved Thesis wil incorporate the canonical url’s as well.

  4. Heads up, everyone; I had to change my block of code in the post above as it had a typo in it. The word “content” has been changed to “href.” Without making that change, the code does absolutely nothing, so be sure to update! :D

Leave a Comment

Your email address will not be published. Required fields are marked *

Use your Gravatar-enabled email address while commenting to automatically enhance your comment with some of Gravatar's open profile data.

Comments must be made in accordance with the comment policy. This site uses Akismet to reduce spam; learn how your comment data is processed.

You may use Markdown to format your comments; additionally, these HTML tags and attributes may be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.

the Rick Beckman archive
Scroll to Top