Archive page not canonicalized to Home

#18830
  • Resolved Alex Ifergan
    Rank Math free

    Hello All,

    DIVI site have a native Blog element, I’ve spot a bug (or let’s call it a non-SEO friendly issue)

    To explicit it, I’d like to see if RankMath could succeed to tackle the issue showing how Yoast Handle it:

    Site1:https://www.adiam.net/
    DIVI based, Home include the Divi Native Blog carrousel (seen at very bottom of homepage) which cause archive pages to be generated (page/2/, page/3/, page/4/)

    In that site, Yoast by default will set canonical tags pointing to the main Home which is the best SEO friendly option, check source of
    https://www.adiam.net/page/2/
    https://www.adiam.net/page/3/
    https://www.adiam.net/page/4/

    Site2:https://www.adiam.net/
    https://eliquide-diy.fr/
    Also DIVI based, also using Divi Native Blog carrousel and also generating https://eliquide-diy.fr/page/2/
    In that site RankMath is running, when you inspect code, you can see that canonical is self one while it should be canonicalized to the homepage.

    Can you think of a patch so rank math can automatically tune canonical tags in an SEO friendly maner so archive page will be canonicalized to the homepage?

    Many thanks

    Alex

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

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

    It is possible to customize the canonical URL returned on the paginated pages by using the following filter on 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 ) {
    	return $canonical;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Thank you Michael

    I just added to my child theme functions.php the advised code: https://snipboard.io/LhrNbd.jpg

    But this solution isn’t helping since https://eliquide-diy.fr/page/2/ as an archive page doesn’t have an unique back-office page. To best explicit my point, please see this quick screen recording: https://drive.google.com/file/d/12PVOdUx5MS129KpK4TOPy9pV0LjrwZFS/view

    Looking for your advice

    Thanks

    Alex

    Hello,

    Thanks for getting back to us.

    You need to customize the logic for this snippet to work, here is an example that may match your use case:

    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	global $wp_query;
            if($wp_query->max_num_pages > 1){
    		$canonical = 'https://eliquide-diy.fr/';
    		return $canonical;
    	}
    	
    	return $canonical;
    });

    I hope this info helps.

    Thanks michael, you rock, the code worked perfectly. Thanks again!!

    Hello,

    We are super happy that this resolved your issue. 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/?rate=5#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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Archive page not canonicalized to Home’ is closed to new replies.