How to noindex, follow a specific category wordpress?
Google appears to be ignoring my robots.txt (despite being valid)
How do I noindex, follow a specific category without plugins?
Topic sitemap robots.txt categories Wordpress
Category Web
Google appears to be ignoring my robots.txt (despite being valid)
How do I noindex, follow a specific category without plugins?
Topic sitemap robots.txt categories Wordpress
Category Web
There are several robots.txt generators online. Here is one of my favorites. After you've generated your file, I highly recommend testing it with Google's Webmaster Tools tester.
I've done this for dozens of sites, and never have a problem.
Just remember the following:
EDIT Google provides the following recommendation, which have also worked for me:
//To prevent only most web crawlers from indexing a page:
<meta name="robots" content="noindex">
- or -
//To prevent only Google web crawlers from indexing a page:
<meta name="googlebot" content="noindex">
EDIT I recommend you use a category template. This WPBeginner Article explains how to create them, in case you have not done this before. Basically, you'll usually start by copying your "index.php" or "page.php" to a new "category.php" file. Then, make a couple of simple edits.
Depending on how many categories should be ignored, my typical suggestion might be to create a single category.php template, then use an "If" statement like the following in the template:
// noIndex = list of categories that should be ignored by bots
$noIndex = array('cats','rats','bats',...);
// current_category = category of the page currently being prepared
$current_category = get_the_category();
// If the current_category is in the list of those to be ignored...
if ( in_array($current_category, $noIndex) ){
// add a filter to insert the meta tag
function ignore_category_indexing() {
echo '<meta name="robots" content="noindex" />';
}
add_action( 'wp_head', 'ignore_category_indexing' );
}
Good luck!
P.S. If this works for you, I could use a Vote Up..
Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.