Removing rel canonical added by Yoast SEO plugin

前端 未结 5 903
难免孤独
难免孤独 2020-12-19 00:09

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

相关标签:
5条回答
  • 2020-12-19 00:45

    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/

    0 讨论(0)
  • 2020-12-19 00:55
    remove_action('wp_head', 'rel_canonical');
    
    0 讨论(0)
  • 2020-12-19 00:57

    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');
    
    0 讨论(0)
  • 2020-12-19 00:59

    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');
    
    0 讨论(0)
  • 2020-12-19 01:00

    You can also disable the canonical urls for wordpress. Look here:Desactivar rel=”canonical” de Yoast WordPress SEO o de WordPress

    0 讨论(0)
提交回复
热议问题