The head section is invisible to visitors and consequential to almost everything else. It is also where cargo cult markup accumulates fastest, because tutorials keep recommending tags that stopped mattering years ago. Here is what belongs there and why.
The three that are effectively mandatory
Character set, viewport and title were covered in the boilerplate, and they are not optional in any practical sense. Every page needs all three, the charset first, and a title that is unique across your site. Nothing below matters if these are missing or wrong.
The description is advertising copy, not a ranking factor
The description meta tag has not been used to decide rankings for a very long time. What it does is supply the text underneath your link in a results page, and that text determines whether anyone clicks. It is the closest thing to free advertising space on the web.
<meta name="description" content="Learn how the HTML head works, which meta tags still matter and which are safely ignored."> Write it as a sentence aimed at a person scanning ten similar results. Around 150 to 160 characters is the usable space before truncation. Say specifically what the page contains, include the terms someone would have typed without forcing them in awkwardly, and give every page its own. Search engines will rewrite it when they think their own snippet fits the query better, which is normal and not a sign you did anything wrong.
The keywords tag is dead
The keywords meta tag was abused so thoroughly in the early days that the major search engines stopped reading it, and have said so publicly for well over a decade. It has no effect on rankings anywhere that matters. Some content management systems still store one for internal search or for their own categorisation, which is a legitimate reason to keep the field populated, but do not imagine you are doing search optimisation by filling it in.
The robots tag controls indexing
This one genuinely instructs search engines, and getting it wrong is expensive.
<meta name="robots" content="noindex, follow"> That combination keeps a page out of search results while still allowing links on it to be followed. It is the right setting for thank you pages, internal search results and duplicate print views. The catastrophic mistake is leaving a noindex on a staging site that later becomes the live site, which quietly removes an entire domain from search. If traffic disappears overnight, this is the first line to check. Note that omitting the tag entirely means index and follow, so there is no need to state the defaults.
The canonical link solves duplicate content
When the same content is reachable at more than one address, and it usually is once you count parameters and trailing slashes, a canonical link tells search engines which address is the real one.
<link rel="canonical" href="https://example.com/html/basics/"> Use the full absolute URL and make it self referencing on every page, meaning each page names itself. That consolidates any ranking signals onto one address instead of splitting them across variations of it.
Open Graph tags control how links look when shared
When a page is pasted into a chat application or a social network, the preview card is built from Open Graph tags. Without them the software guesses, usually badly, and often picks your logo and a fragment of navigation text.
<meta property="og:title" content="The HTML Head Explained"> <meta property="og:description" content="Which meta tags matter and which do not."> <meta property="og:image" content="https://example.com/images/head.png"> <meta property="og:url" content="https://example.com/html/basics/"> The image needs an absolute URL and should be around 1200 by 630 pixels. These four tags take two minutes and noticeably change how often a shared link gets opened.
Stylesheets, scripts and icons
The head is also where you link your stylesheet and your favicon. Scripts can go here too, but a script in the head blocks parsing while it downloads and runs, which delays the page appearing. Adding the defer attribute lets it download in parallel and execute after the document is parsed, which is almost always what you want.
What to leave out
Several tags survive in old templates and do nothing useful. The author, revisit after and rating meta tags are ignored by search engines. So is any tag claiming to declare a language, since the lang attribute on the html element is the actual mechanism. A generator tag naming your editor is harmless but pointless. A head containing only tags that do something is easier to read and easier to trust than one stuffed with inherited habit.