• I tried using the disallow command in the robot.txt file but it’s still showing up in search after a few months. And states “A description for this result is not available because of this site’s robots.txt – learn more/

    That pretty much means I need to put the meta tag noindex nofollow in the header.

    My question would be – could I just paste the meta tag in the header section of the page template of my archives and category pages. I’m careful because I don’t want the noindex nofollow meta tag to affect my entire website for obvious reasons.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Use WordPress SEO by Yoast .It will help you to do no-index categories and archives.

    You can also use the code(given below ) to no-index,nofollw categories and archives.

    Put the code into header.php

    <?php
    if ((is_archive()) && (!(is_category()))) {
    echo '<meta name="robots" content="noindex, nofollow" />';
    }
    elseif ((is_paged()) && (!(is_category()))) {
    echo '<meta name="robots" content="noindex, nofollow" />';
    }
    elseif ((is_single()) || (is_page()) || (is_front_page()) || (is_category())) {
    echo '<meta name="robots" content="index, follow" />';
    }
    else {
    echo '<meta name="robots" content="noindex, nofollow" />';
    }
    ?>

    Thread Starter clouder

    (@clouder)

    Oh yea.

    Do I need to use echo and is “else” necessary?

    Wouldn’t simply using –

    <?php
    
    if (is_archive()) {
    <meta name="robots" content="noindex, nofollow" />;
    }
    
    elseif (is_category()) {
    <meta name="robots" content="noindex, nofollow" />;
    }
    ?>

    suffice?

    Also I don’t have a strong grasp on php so I’m wondering if a simpler solution of just pasting this code into the header of the category.php and archive.php would work just as well?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to noindex categories and archives’ is closed to new replies.