The head element is where a page declares what it is.
Some of it is technical, such as the character encoding, the viewport, and the stylesheet. Some of it is for the search engines. And some of it is for the moment that your page is pasted into a chat, where a title and a preview image decide whether anybody clicks.
The previous lesson in this module covered "How Does Keyboard Focus Order Shape Usability?", and the next lesson in this module is about "How Do You Catch Structure Errors With an HTML Validator?".
Which tags are essential?
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How to Structure a Java Project | Acme</title>
<meta name="description" content="A practical walkthrough of structuring a Java project so the layout makes sense to the next person who opens it.">
<link rel="canonical" href="https://acme.com/articles/java-project-structure">
</head>The charset and the viewport are the technical requirements.
The title and the description are what the people see in the search results.
The canonical link says which URL is the real one when the same content is reachable at several addresses. That is a duplicate, a tracking parameter, or an old trailing-slash variant.
How do the title and the description work?
The title is the single most important on-page signal.
It appears as the blue clickable line in a search result, it appears as the tab label, and it appears as the name of the bookmark.
It has to do two jobs at once. It has to describe the page for a searcher, and it has to fit in the space that the result gives you.
roughly 55-60 characters before the result is truncatedYou put the important words first, because the tail is what gets cut.
The name of the site can go at the end, separated by a vertical bar, and it can be dropped entirely on the pages where the brand is obvious.
What must not happen is a title that is so generic that it describes every page on the site.
The description is the grey summary under the title.
It is not a ranking factor. It has never been used as one, and the search engine that generates the snippet usually rewrites it anyway.
What it does is influence whether the searcher clicks, and that is worth more than a ranking position.
<!-- specific, with a reason to click -->
<meta name="description"
content="A practical walkthrough of structuring a Java project so the layout makes sense to the next person who opens it, with the folder tree and the reasoning behind each layer.">There are two mistakes that make a description useless.
Writing it as a list of keywords, which reads as spam.
And making every page on the site share one, which turns a page into a near-duplicate of every other page on the site.
What are the Open Graph tags for?
When your page is shared in a chat, a messaging app, or a social network, then that service does not take a screenshot of your page.
It reads your metadata, and it builds a card from it.
The Open Graph protocol is the standard for that, and it is four tags.
<meta property="og:type" content="article">
<meta property="og:title" content="How to Structure a Java Project">
<meta property="og:description" content="The folder layout that makes sense, and the reasoning behind each layer.">
<meta property="og:image" content="https://acme.com/images/java-project.png">
<meta property="og:url" content="https://acme.com/articles/java-project-structure">The image is the one that matters most in practice.
A card with a clear preview image and a readable title gets clicked, and a card with no image is a line of text.
The image needs an absolute URL, and it needs to be a reasonable size. The classic failure is a tiny logo that renders as a speck.
There is a matching set for the Twitter-style cards, and the two of them overlap.
If you set both of them, then you use the twitter:card with the value summary_large_image to ask for the large format.
<pre><code class="language-html">
<meta name="twitter:card" content="summary_large_image">
</code></pre>What else belongs in the head?
The meta name="robots" controls the indexing. The noindex keeps a page out of the search results, and it is the right tool for a thin page or a duplicate.
The link rel="icon" is the favicon, and it can be an SVG for a sharp result at any size.
The link rel="preconnect" and the rel="preload" hint to the browser about the resources that it will need.
The meta name="theme-color" sets the colour of the browser interface on a phone.
The link rel="manifest" points to the web app manifest for a site that can be installed.
<pre><code class="language-html">
<link rel="preconnect" href="https://cdn.example.com" crossorigin>
<link rel="preload" as="font" href="/fonts/inter.woff2" type="font/woff2" crossorigin>
<meta name="theme-color" content="#800d4d">
</code></pre>What is the structured data?
The metadata describes the page for the machines, and the structured data describes the page for the search engines in a machine-readable form, so that a search result can include more than a title and a snippet.
It is written as JSON-LD, which is a block of script that is embedded in the page.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "How to Structure a Java Project",
"description": "The folder layout that makes sense, and the reasoning behind each layer.",
"datePublished": "2026-10-14",
"author": { "@type": "Person", "name": "Alex Doyle" },
"image": "https://acme.com/images/java-project.png"
}
</script>It is worth knowing about, and it is worth being careful with.
The vocabulary is large, and the rules are strict. A wrong value is worse than no value, because a structured data block that contradicts the page itself is a signal that the markup is untrustworthy.
You start with the type that matches what the page really is, you keep the values identical to what a reader would see on the page, and you validate the block with the testing tool of the search engine before you rely on it.
What about the language of the page?
The lang attribute on the html element is part of the metadata for the page, because it tells the search engines which language the page is in, and that matters for a site that publishes in several languages.
<html lang="en-GB">
...
</html>
<!-- a page in another language, inside the same document -->
<p lang="fr">Une phrase en français</p>Using a region as well as a language, such as the en-GB rather than just the en, is useful when the spelling and the formatting differ between the markets. It is what lets a site offer the regional variants of the same content without confusing a search engine about which page is for whom.
Quick reference
- meta name="robots" controls the indexing. The noindex keeps a page out of the search results, and it is the right tool for a thin page or a duplicate.
- link rel="icon" is the favicon, and it can be an SVG for a sharp result at any size.
- link rel="preconnect" and rel="preload" hint to the browser about the resources that it will need.
- meta name="theme-color" sets the colour of the browser interface on a phone.
- link rel="manifest" points to the web app manifest for a site that can be installed.
- The charset and the viewport are the technical requirements, and the title and the description are for the people.
- You put the important words first in the title, because the tail gets truncated.
- The description is a click-through lever and not a ranking factor, and it has to be unique per page.
- The Open Graph tags control how a shared link looks, and the image matters most.
- You use the noindex for the pages that should not appear in the search results.
Try it yourself: you write the head for a page that you have, and you keep the title under sixty characters, and the description between one and two sentences.
You paste the link of the page into a chat app that renders the previews, and you see whether the card shows your title and your image, or whether it falls back to something generic.