Tag found outside the document head which is only allowed as a direct child of the document head

By | 12th November 2019

You might be facing with this issue:”Tag found outside the document head which is only allowed as a direct child of the document head.” on your website. I had faced the same problem for my website.

Tag found outside the document head which is only allowed as a direct child of the document head

When I went to google search console to find the performance of my website. I found that most of my pages were getting the errror: “Tag found outside the document head which is only allowed as a direct child of the document head.”

I tried searching for a solution on google and going through various websites I was not able to find a proper solution for the same.

Some of the solutions I went for deleting some of my WordPress add ons. Some suggested solutions on web were to crawl my pages again. Even this also not sorted my problem.

This problem usually arises in amp pages.

AMP stands for Accelerated Mobile Page. AMP pages are nothing but are web pages that can easily run on mobiles.

This error makes your website pages invalid for google search results. Hence, your pages will not rank in google search results.

One of the solution to this problem is you have to validate your pages and test your amp code at https://search.google.com/test/amp . You just need to put the URL of your page and you can see the code that is creating the error.

The error is usually caused by not using the standard format of images, logo etc as per the specified norms of amp pages.

Other most important factors leading to this error is different scripts and wp plugins which are not compatible with amp pages. Now , I will tell you the steps you should follow in order to get rid of the error.

  1. You have to go to your wordpress dashboard.
  2. Now go to plugins and select AMP plugin, install and activate it.
  3. After installing it go to General in AMP.
  4. Here you have to select website in Experiences.
  5. Now the most important part , the Website mode Standard, Transitional and Reader.
  6. Here if you select Reader Mode then your site will not be in AMP mode.
  7. If you select Transitional and Standard mode than your website will be AMP compatible. So, in order to resolve the error you need to select one of the Transitional or Standard mode.
  8. Now go to each individual page or posts on your website and update. Now, your website is AMP ready and the error Tag found outside the document head which is only allowed as a direct child of the document head will be gone.
  9. In your AMP you will get your validated pages and Error Index.

Hope this solves your problem.