Polylang vs RankMath: Canonical link + og:url are displayed twice in Blog Archiv

#840740
  • Resolved Ronny Fischer
    Rank Math free

    Hello, I am aware of the general problem of compatibility between RankMath and Polylang.

    I have followed all the steps on this website and also used the (new) code:
    https://rankmath.com/kb/polylang-compatibility/

    So far so good. But I have a problem with the blog page (archive). I found this article about it:
    https://wordpress.org/support/topic/error-with-canonical-link-and-ogurl-on-main-blog-page/

    In my case as well, the rel=”canonical” and property=”og:url” are displayed twice, both on the English and on the German page.

    The EN blog page has the URL: domain.de/xxx-xxx-xxx/
    The DE blog page has the URL: domain.de/de/yyy-yyy-yyy/

    (Even though the domain extension is .de, English is the main language)

    An archive template was created with Elementor that displays all blog posts and applies to both languages.

    I have already entered the respective URLs in the RankMath Canonical settings. Unfortunately, there are no changes even after several cache deletions.

    What solution is there for this? Unfortunately, no solution is mentioned in the above blog post.

    Thank you very much!
    Ronny

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

    I apologize for the issue you are facing with the duplicate display of rel="canonical" and property="og:url" on your blog archive pages when using Rank Math and Polylang.

    To address this problem, you can try the following steps:

    1. Check Canonical Settings in Rank Math:

      • Ensure that you have correctly entered the respective URLs in the Rank Math Canonical settings for both the English and German blog pages.
      • Verify that the canonical URLs are set up correctly in Rank Math’s Advanced Meta Box for each blog post.
    2. Review Custom Code:

      • Double-check the custom code added for Polylang compatibility as per the instructions provided in the Rank Math knowledge base article.
      • Make sure that the code is correctly implemented in your theme’s rank-math-ppl.php file.
    3. Elementor Archive Template:

      • Review the Elementor archive template settings to ensure that there are no conflicting settings causing the duplication of canonical URLs.
      • Check if there are any specific settings within Elementor affecting the display of canonical URLs on the blog archive page.
    4. Cache Clearing:

      • After making any changes or adjustments, clear all caches, including any server-side caching, WordPress caching plugins, and browser cache, to ensure that the changes take effect.

    If after following these steps, the issue persists, I recommend reaching out to our support team directly by replying to this ticket. Our team will investigate further and provide you with personalized assistance to resolve the problem.

    Thank you for your understanding, and we appreciate your patience as we work to address this issue for you.

    Best regards.

    Sources:
    How to Make Polylang Compatible With Rank Math
    How to Fix “Duplicate, Google Chose Different Canonical than User” » Rank Math
    How to Fix ‘Duplicate Without User-Selected Canonical’ Status in Google Search Console » Rank Math

    I have already double-checked all functions, emptied all caches several times, and tried different browsers.

    The code provided by RM works quite well, as I can translate all ACF and Elementor archives with Polylang. And all translations are displayed correctly in the source code. The Canonical and OG urls are also correct in these archives.

    The blog archive is the only page where this error occurs.

    When I open the blog page in WordPress, the Rank Math Canonical URL field already contains the correct URL (by default). Even if I manually retype this URL, nothing changes in the source code. The URLs are still displayed twice.

    I don’t think I’m the only one experiencing this. I have now found several pages like this one. Unfortunately there is no solution mentioned anywhere.
    https://support.rankmath.com/ticket/the-canonical-tags-are-duplicated/

    Thank you for your help!

    Hello,

    Kindly remove any canonical URL you might have added in the Rank Math meta box within the edit area of the blog page archive and add the following filter to your site:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        if ( is_home() || is_archive() ) {
            $canonical = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        }
        return $canonical;
    });

    This code checks if the current page is a blog page archive (is_home()) or any type of archive page (is_archive()). If so, it sets the canonical URL to the current URL. If not, it leaves the canonical URL unchanged.

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Let us know if you need any other assistance.

    Yes, perfect. It works.
    og:url and canonical:url now have the correct page URLs in the appropriate language and are no longer duplicated.

    Perhaps it would be a good idea to include this filter in the rank-math-ppl, as I think other users have the same problem, and so there is no need to include extra code in addition to the two RankMath PHP files.

    Thanks for the help!

    Hello,

    We appreciate your feedback. It is valuable to us and helps us improve our services.

    We are glad to know that this issue has been resolved. Thank you for letting us know.

    This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.

    We appreciate your patience and cooperation throughout this process.

    Thank you for choosing Rank Math.

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

The ticket ‘Polylang vs RankMath: Canonical link + og:url are displayed twice in Blog Archiv’ is closed to new replies.