3

Is it completely fine to add rel=canonical tag outside the head section?

I ran a website audit and the crawler highlighted the issue to have rel=canonical tag inside the head tag.

1
  • Do you know if the canonical is being set by a plugin or by the theme you are using?
    – keepkalm
    Oct 13, 2023 at 14:39

1 Answer 1

3

https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls

The following text is highlighted in the official Google documentation:

If you use a CMS, such as WordPress, Wix, or Blogger, you might not be able to edit your HTML directly. Instead, your CMS might have a search engine settings page or some other mechanism to tell search engines about the canonical URL. Search for instructions about modifying the <head> of your page on your CMS (for example, search for "wordpress set the canonical element")

This means that we need to put the codes that I want to notify the Google bot between <head>.

So in this case, your code should be located between codes.

<head>
    <link rel="canonical" href="https://www.example.com/url">
</head>
4
  • 1
    It's easy enough to find the code and put it into header.php in whatever theme you are using. I would consider that a temporary fix. It will go away when you update the theme.
    – keepkalm
    Oct 13, 2023 at 14:37
  • 1
    @keepkalm Yes, you are right, I quoted it because it says add to head.html in this text because it writes a text about where we should add the code in the Google documentation. In fact, they gave another answer in another answer. Oct 13, 2023 at 14:40
  • 1
    I think your answer is correct, just wanted to add some context regarding CMS and future updates. Canonical could be set by a plugin also. I run into this all the time with a plugin I use that uses job schema incorrectly, I fix it, left a note for the developer, hope it gets fixed in a future version.
    – keepkalm
    Oct 13, 2023 at 14:45
  • @keepkalm Yes, you are right and thank you. Oct 13, 2023 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.