I have a website built with WordPress and I want to noindex my tag pages but I’ve noticed that, although I’ve marked them as noindex, Yoast SEO plugin still adds rel=canonical tag.
Google says rel=canonical and noindex directives must not be together. So, I tried to remove canonical tag adding the following code to my functions.php file:
if ( is_tag() ) {
add_filter( 'wpseo_canonical', '__return_false' );
remove_action('wp_head', 'rel_canonical');
}
But nothing happened. The canonical tag is still there.
Do you know how I can remove it?
2
Answers
By adding only this code to your functions.php you can remove rel=”canonical” tag:
Edit tag.php file in your theme’s directory and remove the concerned code or add a file named tag-slug.php to your theme’s directory and then build a custom template for your tag archives.