Final week we reported on a remark made by John Mueller of Google concerning the head part of your HTML and why you need to preserve it clear. John, on Friday, posted a Mastodon thread explaining extra concerning the head part and the way search engines like google and yahoo 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 once in a while, I assumed I would 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 should be discovered within the head of a web page with a view to be legitimate. In case 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 considering of are the robots meta tag & the canonical hyperlink aspect, however there’s additionally the title & description meta tag which some folks contemplate vital. It isn’t nearly search engine optimization both – you in all probability additionally need to make sure that issues just like the character set definition, viewport & CSP are thought-about legitimate.
“In fact my head is okay” – generally it is not as apparent as clearly damaged markup. The top is self-closing, so any HTML aspect that is not legitimate within the
will end in the remainder to be thought-about as part of the physique. That may be a stray img that finally ends up someplace flawed, it may very well be an iframe {that a} script injects to the highest of the pinnacle throughout rendering. That is seen in case you examine the DOM of a web page in your browser.
Browsers are generally useful and attempt to interpret what you imply, if you don’t need a web page to be listed, or desire a totally different URL as canonical, you in all probability don’t desire search engines like google and yahoo to guess. (search engine optimization is to a big half about not making search engines like google and yahoo guess.)
In brief, keep away from making the pinnacle brittle in case you care about these search engine optimization settings, contemplate shifting them to the highest of the pinnacle (do not embrace 5k traces of JS above them), and double-check the rendered DOM in your browser once in a while.
You do not have to maneuver it into the physique (that may trigger different issues), I would transfer it to beneath the vital parts that it is advisable 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 – acquired it?
Discussion board dialogue at Mastodon.