Final week we reported on a remark made by John Mueller of Google concerning the head part of your HTML and why it’s best to maintain it clear. John, on Friday, posted a Mastodon thread explaining extra concerning the head part and the way search engines like google work together with it, particularly if there’s a number of JavaScript in it.
Right here is the content material from the thread:
search engine optimisation in your head vs an excessive amount of #JavaScript?
This comes up now and again, I assumed I might be extra elaborate as soon as (it is not new). Search engines like google (I solely actually know Google, YMMV) render HTML pages and there are some settings that must be discovered within the head of a web page with a purpose to be legitimate. For those who care about these settings, do not make the
brittle, and ideally transfer these settings to the highest of the top.
The search engine optimisation 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 individuals contemplate vital. It isn’t nearly search engine optimisation both – you most likely additionally wish to be certain issues just like the character set definition, viewport & CSP are thought of legitimate.
“In fact my head is okay” – generally it is not 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 flawed, it might be an iframe {that a} script injects to the highest of the top throughout rendering. That is seen in the event you examine the DOM of a web page in your browser.
Browsers are generally useful and attempt to interpret what you imply, if you do not need a web page to be listed, or desire a totally different URL as canonical, you most likely don’t desire search engines like google to guess. (search engine optimisation is to a big half about not making search engines like google guess.)
Briefly, keep away from making the top brittle in the event you care about these search engine optimisation settings, contemplate transferring them to the highest of the top (do not embody 5k strains of JS above them), and double-check the rendered DOM in your browser now and again.
You do not have to maneuver it into the physique (that may trigger different issues), I might transfer it to under the important parts that you want to have found within the head.
— John Mueller is generally not right here 🐀 (@JohnMu) January 13, 2023
That’s the finish of his head thread – obtained it?
Discussion board dialogue at Mastodon.