Canonical tag removed from home page

#967311
  • Hony
    Rank Math free

    My theme includes canonical tag on the home page, but rankmath is removing this.

    The theme is EXTRA by Elegant Themes. It uses a builder to define the homepage, it isn’t a “page” so there is no were to define a custom canonical.

    How can I stop rankmath from removing the existing canonical from the homepage?

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

    We apologize for the issue you are facing with the canonical tag on your homepage. Since your theme is using a builder and does not provide a direct option to set a custom canonical URL, Rank Math may be overriding the canonical tag that your theme adds.

    To prevent Rank Math from removing the existing canonical tag, you can try the following steps:

    1. Disable Canonical URL in Rank Math: You can disable the canonical URL feature for your homepage. To do this, navigate to the Rank Math settings in your WordPress dashboard and look for the option to disable the canonical URL for specific pages or posts.

    2. Use a Filter Hook: If you are comfortable with coding, you can use a filter hook in your theme’s functions.php file to retain the canonical tag added by your theme. Here’s an example of how you might do this:

      add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
         if ( is_front_page() ) {
             return ''; // Return an empty string to prevent Rank Math from adding its own canonical tag.
         }
         return $canonical;
      });

      This code snippet will stop Rank Math from adding its own canonical tag on the homepage.

    3. Contact Theme Support: Since you are using a specific theme (EXTRA by Elegant Themes), it might be beneficial to reach out to their support team for guidance on how to manage canonical tags effectively with their builder.

    If these solutions do not resolve the issue, please reply to this ticket with more details about your setup, and a human agent from our support team will assist you further. Thank you for raising this concern!

    Sources:
    Alternate Page with Proper Canonical Tag Status in Google Search Console » Rank Math

    This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.

    Hony
    Rank Math free

    How to do this:

    Disable Canonical URL in Rank Math: You can disable the canonical URL feature for your homepage. To do this, navigate to the Rank Math settings in your WordPress dashboard and look for the option to disable the canonical URL for specific pages or posts.

    I can’t find any option for “disable the canonical URL for specific pages or posts.”

    Hony
    Rank Math free

    I also tried the functions.php you suggested, that does not work.

    Hello,

    Could you please share your homepage URL so we can check?

    Rank Math adds self-referencing canonical URLs as long as it is set to index.

    Looking forward to helping you.

    Hony
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    We checked your homepage and we can also confirm the canonical URL is not added there. In this case, please follow this guideline to check if any other plugins/themes are conflicting with Rank Math: https://rankmath.com/kb/check-plugin-conflicts/

    Meanwhile, you can use the following filter on your website to force Rank Math to add the canonical URL:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	global $wp;
    	$current_slug = home_url( $wp->request );
        
    	if( is_front_page() || is_home() ){
            $canonical = $current_slug;
        }
    	return $canonical;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thank you.

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

You must be logged in to reply to this ticket.