WordPress.org

Ready to get started?Download WordPress

Forums

Elbee Elgee
[PATCH] Google "duplicate content feature" improvement (2 posts)

  1. Daedalon
    Member
    Posted 1 year ago #

    Header.php has a code that outputs <!-- ok google, index me! --> or <!-- google, please ignore - thanks! --> in the top of every page. We wanted to remove this both to avoid printing unnecessary HTML and to avoid sending invalid information: most of the pages were displaying the comment for welcoming Google without any regard to robots.txt blocking all search engines.

    While removing the HTML comments we also decided to simplify the if clause. Original code starting from line 11 in header.php:

    <?php
    // Head that nasty "duplicate content" Google "feature" off at the pass.
    	if((is_single() || is_category() || is_page() || is_home()) && (!is_paged())){
    	?>
    	<!-- ok google, index me! -->
    	<?php
    	}else{
    	?>
    	<!-- google, please ignore - thanks! -->
    	<meta name="robots" content="noindex,follow">
    	<?php
    	}

    Simplified code without the else clause and HTML comments:

    <?php
    	// Head that nasty "duplicate content" Google "feature" off at the pass.
    	if ( is_paged() || ! ( is_single() || is_category() || is_page() || is_home() ) ) {
    		?><meta name="robots" content="noindex,follow"><?php
    	}

    The if clause was a bit tricky, but should have exactly the same functionality in both. Here's the breakdown of the original:

    • Do not block the search engines if ! is_paged() AND any one of the list is true (list: is_single(), is_category() etc.)
    • Block the search engines if is_paged() OR none of the list are true.

    The new code has only the latter part since the first wouldn't create an action. Code was formatted to match the WordPress Coding Standards.

    If someone would like to test this also on their site, that'd be great. If no one encounters any problems in a reasonable time frame, I'll submit this into the Elbee Elgee repository for Doug to consider adding to the next update.

    http://wordpress.org/extend/themes/elbee-elgee/

  2. Doug
    Member
    Theme Author

    Posted 1 year ago #

    I'll consider it, but I think it may actually be plugin territory, thus I may well just remove that section entirely.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic