skip to Main Content

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


  1. By adding only this code to your functions.php you can remove rel=”canonical” tag:

    add_filter( 'wpseo_canonical', '__return_false' );
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search