With comment pagination, Google doesn't index the older pages and comments become essentially lost to searches.

Is there a way to let search engines crawl paginated comments, perhaps by generating a sitemap file that includes all paginated comments?


The reason of why Google doesn't index paginated comments is because of an issue with the canonical URL in your header. You can learn more about the reason behind this in a comprehensive question that I posted earlier. There is an excellent solution posted there for paginated post pages.

Now, for Google to index comment pagination, bungeshea posted an answer for a while ago when he (by accident) solved this when actually aiming to fix indexing for post pagination.

Luckily, I saved that code:

function comment_rel_canonical() {

    if ( ! is_singular() )

    global $wp_the_query;

    if ( ! $id = $wp_the_query->get_queried_object_id() )

    $link = get_permalink( $id );

    if ( $page = get_query_var('cpage') )
        $link = get_comments_pagenum_link( $page );

    if ( $paged = get_query_var( 'paged' ) )
        $link = add_query_arg( 'paged', get_query_var( 'paged' ), $link );

    printf ( '<link rel="canonical" href="%s" />\n', $link );

remove_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_head', 'comment_rel_canonical' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.