Final week we reported on a remark made by John Mueller of Google in regards to the head section of your HTML and why you should keep it clean. John, on Friday, posted a Mastodon thread explaining extra in regards to the head part and the way engines like google work together with it, particularly if there may be a whole lot of JavaScript in it.
Right here is the content material from the thread:
search engine optimization in your head vs an excessive amount of #JavaScript?
This comes up every so often, I assumed I might be extra elaborate as soon as (it isn’t new). Search engines like google (I solely actually know Google, YMMV) render HTML pages and there are some settings that have to be discovered within the head of a web page as a way to be legitimate. When you care about these settings, do not make the
brittle, and ideally transfer these settings to the highest of the pinnacle.
The search engine optimization settings I am pondering of are the robots meta tag & the canonical hyperlink factor, however there’s additionally the title & description meta tag which some folks take into account necessary. It isn’t nearly search engine optimization both – you in all probability additionally need to ensure issues just like the character set definition, viewport & CSP are thought of legitimate.
“In fact my head is okay” – typically it isn’t as apparent as clearly damaged markup. The pinnacle is self-closing, so any HTML factor that is not legitimate within the
will end in the remaining to be thought of as part of the physique. That may be a stray img that finally ends up someplace mistaken, it could possibly be an iframe {that a} script injects to the highest of the pinnacle throughout rendering. That is seen for those who examine the DOM of a web page in your browser.
Browsers are typically useful and attempt to interpret what you imply, if you do not need a web page to be listed, or need a completely different URL as canonical, you in all probability don’t desire engines like google to guess. (search engine optimization is to a big half about not making engines like google guess.)
In brief, keep away from making the pinnacle brittle for those who care about these search engine optimization settings, take into account shifting them to the highest of the pinnacle (do not embody 5k strains of JS above them), and double-check the rendered DOM in your browser every so often.
You do not have to maneuver it into the physique (that may trigger different issues), I might transfer it to beneath the vital parts that you must have found within the head.
— John Mueller is generally not right here 🐀 (@JohnMu) January 13, 2023
That’s the finish of his head thread – acquired it?
Discussion board dialogue at Mastodon.