According to Google’s John Mueller, the placement of HTML can significantly affect your ranking. He suggests, placing JavaScript code below the HTML header tag to ensure crawlers can fully understand your website.
A Reddit user asked whether an HTML code placement can affect SEO, Mueller responds, and shares his advice in a Reddit thread:
So, we know that HTML code needs to appear on top of the page to support SEO efforts. Meuller adds, the top part needs to be ‘clean’ and any JavaScript code should be placed below the HTML headers. To ensure the JavaScript isn’t interfering with the <head> section, Mueller recommends using the rendering tool in Search Console which enables you to test how Google crawls a page on a website, along with how they visually render it on mobile and desktop devices.
The main content placement is not as important, but the head section is the only crucial placement and needs to also be clean for Google bots to understand, so keeping javascript out of the head section is important.
The Google Tag Manager box placement is different in every situation according to Meuller. On the Google support page, it says, “Copy and paste the code snippets into your website as instructed in the Install Tag Manager box. Place the <script> code snippet in the <head> of your web page’s HTML output, preferably as close to the opening <head> tag as possible, but below any dataLayer declarations.” Mueller recently suggested that “Every situation is different. I’d look at what you do with GTM, test it in a browser & with the testing tools.”
We hope this helped clarify some of your technical search engine optimization questions. Follow us for the latest updates and tips on SEO-related topics.