canonical link for home page

#205751
  • Resolved Rachel Alexander
    Rank Math free

    How can you REMOVE the canonical for the home-page of the site. When I go to edit this I have to put in a space to hide the site url. I don’t want this <link rel=”canonical” href=”https://example.com/&#8221; /> basically being a canonical of itself – or does this not matter?

    Thanks in advance

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

    Thanks for contacting us and sorry for any inconvenience that might have been caused due to that.

    Having a canonical URL the same as the page URL means that this page is original and not a duplicate of some other page. If you want to remove the canonical tag from your homepage then you can copy the code given below and paste it into your theme’s functions.php file:

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

    Hope this helps. Let us know if you need any further assistance.

    Thanks – this code works well .. FYI I added using Code Snippets.
    This is something that may affect other RankMath users ..
    I’m still unsure of the impact of this on page ranking but don’t want to risk it on the homepage.
    Thanks again for your speedy resolution!

    Hello,

    We are super happy that your issue is resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘canonical link for home page’ is closed to new replies.