How to add the hreflang rel=”alternate” attribute just after section

#502549
  • Resolved Razi Hussain
    Rank Math free

    Hi,

    I’m here for my hreflang query because whenever I come here, I got exact solutions, so hope today as well.

    The query is:

    Since I have 2 versions of similar pages in different languages, so as per google, defining an hreflang link for each version of a page is a must for a better understanding of the content for google bots.

    So, I want to add the hreflang rel=”alternate” attribute just after <head> section. So, if I add that rel=”alternate” tags directly in the header.php file then it will be displayed in all pages & posts, but I want to add this tag only for specific posts or pages. And I have checked but there is no setting in Rankmath to do that.

    So, please let me know how can I do that.

    Looking forward to your kind response.

    Thank you!
    Razi

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

    Thanks for contacting us and sorry for the inconvenience caused.

    The hreflang is managed by the translation plugin you are using. If you are not using a translation plugin, you can follow this guide to add it manually: https://www.wpbeginner.com/plugins/how-to-add-hreflang-tags-in-wordpress/

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

    Hi Jaideep,

    Thanks for your response,

    Actually, I don’t use a translation plugin, I do it manually, is it possible to add hrefland rel=”alternate” attribute without any plugin? I don’t want to use HREFLANG Tags Lite plugin.

    If so, then very curious to know how to do that.

    Regards,

    Hello,

    To add those without any plugin you need to create a filter that hooks into the wp_head and manage the tags from there for each page.

    You can see examples and documentation on that hook here: https://developer.wordpress.org/reference/hooks/wp_head/

    If you are not familiar with PHP and WordPress coding you might need to hire a developer to create those code snippets.

    Don’t hesitate to get in touch if you have any other questions.

    Hi Miguel,

    Thanks for your response,

    I will highly appreciate you or anyone if you can provide me with the exact solution on how to do that.

    Regards,

    Hello,

    If you are not sure then you should hire a developer to do this. Or you can use the plugin mentioned in the article I shared to easily add and manage the hreflang tags.

    Let us know if you need any other assistance.

    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 5 replies - 1 through 5 (of 5 total)

The ticket ‘How to add the hreflang rel=”alternate” attribute just after section’ is closed to new replies.