Delete all canonical

#104625
  • Resolved Ilvir-hzrd
    Rank Math free

    Hello, how can I remove all canonical links on the site? And is it possible to specify custom canonical urls on filter results pages?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Rank math adds self canonical URLs to all pages set to index. You can also specify custom canonical on the individual pages under the Advanced tab of Rank math meta box: https://i.rankmath.com/yRtXjc . You should however note adding a custom URL this way may keep a page from being added to the sitemap as this is usually intended for duplicate pages.

    You can however specify the canonical using this filter:

    
    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	return $canonical;
    });
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Hello it didn’t work. Maybe I am doing something wrong, but the canonical url all stayed.

    Michael Davis
    Rank Math pro

    Hello,

    You can simply set the pages to noindex which would automatically remove the canonical on your pages. To remove all canonical URLs using the filter, use it as follows in your theme functions.php file:

    
    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	$canonical = "";
    	return $canonical;
    });
    

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Delete all canonical’ is closed to new replies.