Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing rel canonical added by Yoast SEO plugin

Tags:

wordpress

Couldn't find a solution after a quick google so thought i'd pop a quick post on here.

Trying to remove a automatically added rel=canonical link (which is added by Wordpress SEO plugin - by Yoast).

I actually want google to crawl each of the different subs even though it may not move away from the parent page.

like image 293
David Avatar asked May 10 '12 07:05

David


People also ask

How do I remove canonical from Yoast?

You can remove the canonical URL from being output by using the wpseo_canonical developer filter. You can use the following code example and add this to your site's functions. php file in order to implement it: add_filter( 'wpseo_canonical', '__return_false' );

How do I remove canonical link?

Open the Actions menu of Page and then choose Title & Properties. Expand Advanced options section. In Canonical Urls dropdown box, select whether you want to enable or disable canonical URLs for the page.

How do I remove canonical links in WordPress?

Just install WP Adminify plugin and navigate to WP Adminify > Tweaks > Head area. Search for Remove Canonical URL option. Enable this option, save your plugin settings. Then reload your webpage and check for the canonical URL in its page source.


3 Answers

rel="canonical" has nothing to do with crawling. It has to do with indexing and prevents the same page from indexing twice or more.

Anyway, if you still want to do this you can do it by adding this code to your functions.php:

add_filter( 'wpseo_canonical', '__return_false' );

Source: https://yoast.com/wordpress/plugins/seo/api/

like image 100
nautilus7 Avatar answered Oct 14 '22 06:10

nautilus7


You can also use this in wordpress conditional tags

Refer: https://codex.wordpress.org/Conditional_Tags

// Remove - Canonical for - [Search - Page]
function remove_canonical() {

    // Disable for 'search' page
    if ( is_search() ) {
        add_filter( 'wpseo_canonical', '__return_false',  10, 1 );
    }
}
add_action('wp', 'remove_canonical');

Remove canonical for ALL pages.

// Disable Canonical for - ALL pages
function remove_canonical() {
    add_filter( 'wpseo_canonical', '__return_false',  10, 1 );
}
add_action('wp', 'remove_canonical');
like image 37
maheshwaghmare Avatar answered Oct 14 '22 05:10

maheshwaghmare


most likely the canonical is not generated by yoast, there is a wordpress inbuilt function you can prevent it by adding this to your theme´s functions.php

remove_action('wp_head', 'rel_canonical');
like image 1
john Smith Avatar answered Oct 14 '22 06:10

john Smith