Since the first lesson of the course, the head of your pages has contained much the same: meta charset, meta viewport and a title. That has been enough for the browser to display the pages properly, but the head can do much more. It is where you write the metadata: information about the page that doesn't appear in its content, but which is read by search engines to build their results, by social networks and messaging apps to generate the preview card when someone shares a link, and by the browser itself to show the tab icon or the colour of the bar on a mobile phone. In this lesson you will go through the head in depth: you will learn to write an effective title and description, to give instructions to search engines, to avoid duplicate content with the canonical URL, to add icons and, with the Open Graph protocol and X (formerly Twitter) cards, to control how The Blue Cup looks when it's shared.

Contents

  1. What metadata is and who reads it
  2. An effective title
  3. meta name="description"
  4. meta name="robots": instructions for search engines
  5. The canonical URL: link rel="canonical"
  6. Icons: favicon and apple-touch-icon
  7. Other metadata: theme-color, author and generator
  8. Versions in other languages: hreflang (in passing)
  9. Open Graph: cards when sharing
  10. X cards (Twitter Cards)
  11. How to preview and check the metadata
  12. meta keywords: why it's no longer any use
  13. Project: The Blue Cup's complete head

What metadata is and who reads it

Metadata is "data about data": it describes the page instead of being part of its content. In HTML it is written in the head, mainly with two void elements:

  • meta: a name-value pair. Depending on the case, the name goes in name, in property or in http-equiv, and the value in content.
  • link: a relationship with another resource (an icon, another version of the page, a stylesheet), indicated with rel and href.
<meta name="description" content="Neighbourhood café and bakery with sourdough bread.">
<link rel="icon" href="img/favicon.png">
Who reads it What it's interested in
Browser charset, viewport, title, icons, theme-color
Search engines (Google, Bing…) title, description, robots, canonical, hreflang
Social networks and messaging (WhatsApp, LinkedIn, Facebook, X, Telegram…) Open Graph (og:*), X cards (twitter:*)
Screen readers title and the document's lang
graph LR
    H["Page head"] --> N["Browser: tab, icon, colour"]
    H --> B["Search engine: result with title and description"]
    H --> R["Social network: card with image, title and description"]

You already know two pieces of metadata that we won't repeat here: meta charset="utf-8" (Basic Structure of an HTML Document and HTML Entities) and meta name="viewport", which you will study in depth in The Viewport Meta Tag. Nor will we look at linking stylesheets with link rel="stylesheet" now: that is the subject of Linking CSS to HTML.

SEO (Search Engine Optimisation) is the set of techniques for making a website rank well and look good in search engines. Metadata is only one part of it: the most important factor is still useful, well-structured content, which is what you have been building throughout the course with headings, semantics and descriptive text.

An effective title

The title isn't just another piece of metadata: it is the piece of metadata. It appears in the browser tab, in bookmarks and in the history, it's the first thing a screen reader announces when the page opens, and it is usually the blue headline in search results.

At The Blue Cup you use the pattern "Page | The Blue Cup". Guidelines for making it effective:

  • Unique on each page: two pages with the same title confuse users and search engines.
  • The specific part first, the brand at the end: in a narrow tab or a truncated result, what distinguishes the page is seen first.
  • Short: around 50–60 characters. Any longer and the search engine cuts it off with "…".
  • Descriptive and natural: written for people, not a list of keywords.
  • Consistent with the h1, without necessarily being identical (the convention you established in module 2).
Could be better Better Why
Home The Blue Cup, neighbourhood café and bakery "Home" means nothing outside the website
The Blue Cup (on every page) Menu and prices | The Blue Cup Each page needs its own title
Coffee, café, cheap coffee, best coffee, croissant, bread Menu and prices | The Blue Cup Repeating keywords looks like spam
The Blue Cup | Menu Menu and prices | The Blue Cup The specific part first

On the home page, the pattern changes slightly: "Home | The Blue Cup" makes no sense. Use the brand with a short description of what it is.

meta name="description"

The description is a summary of the page's content in one or two sentences:

<meta name="description" content="Neighbourhood café and bakery in Fictional Town: speciality coffee, pastries and freshly baked sourdough bread every day. Open from 8:00 to 20:00.">
  • It isn't visible on the page.
  • Search engines usually use it as the grey text under the title in the results. I say "usually" because, if they consider that another passage of the page answers the search better, they use that instead.
  • It doesn't directly affect the result's position, but a good description makes more people click.

Guidelines:

  • Unique for each page.
  • Around 120–160 characters: what fits without being cut off in most results.
  • It should say what the user will find and, where relevant, why it's of interest to them.
  • No straight double quotes inside the value (they would break the attribute; remember HTML Entities): use curly quotes “ ”.

meta name="robots": instructions for search engines

Search engines go through the web with automated programs called robots or crawlers. By default, they index (add to their results) every page they find and follow its links. The robots meta tag lets you change this page by page:

<meta name="robots" content="noindex, follow">
Value Meaning
index You can show this page in the results (this is the default)
noindex Don't show this page in the results
follow You can follow the links on this page (default)
nofollow Don't follow the links on this page
noarchive Don't keep a cached copy
nosnippet Don't show text snippets under the title
max-image-preview:large You can show large previews of the images
  • If you want the page to appear normally, don't add anything: index, follow is the default behaviour. Writing it isn't a mistake, but it adds nothing.
  • noindex is used on pages that there's no point in finding from a search engine: "thank you for your booking" pages, internal search results, drafts or test environments.
  • noindex is a request that reputable search engines respect. It isn't security: a page with noindex is still public for anyone who has the link.

There is also the robots.txt file, at the root of the site, which tells crawlers which areas they shouldn't visit. It's a text file, not HTML, and we will mention it when we publish the site in Testing and Deployment.

The canonical URL: link rel="canonical"

Often, the same page can be reached from several addresses:

  • https://thebluecup.example/
  • https://thebluecup.example/index.html
  • https://www.thebluecup.example/
  • https://thebluecup.example/?source=newsletter

To a search engine, in principle, these are four pages with the same content: duplicate content, which splits the relevance between several addresses. The canonical URL tells it which is the "official" address:

<link rel="canonical" href="https://thebluecup.example/">
  • It goes in the page's head and points to the preferred version, even from the preferred version itself (self-referencing: this is what's recommended).
  • The href must be an absolute URL, with https:// and the domain.
  • The other addresses of the same page will carry the same link and the search engine will group them all under the canonical one.

About absolute paths: since module 1, your convention has been to use relative paths. Metadata read by external programs (canonical, Open Graph, hreflang) is the exception: a search engine or a social network reads the page outside your site and needs the full address. Icons (link rel="icon"), on the other hand, are read by the browser itself and can use a relative path.

Icons: favicon and apple-touch-icon

The favicon is the small icon that appears in the browser tab, in bookmarks and, sometimes, next to the result in search engines.

<link rel="icon" href="img/favicon.svg" type="image/svg+xml">
<link rel="icon" href="img/favicon.png" sizes="32x32" type="image/png">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
  • rel="icon" declares the page's icon. You can offer several: the browser chooses the one that suits it best.
  • SVG is ideal (a single file that looks sharp at any size), but not every browser supports it as a favicon; that's why a 32×32 PNG is added as a fallback. sizes gives the dimensions and type the format.
  • rel="apple-touch-icon" is the icon used by iPhone and iPad when someone adds the website to their home screen. The usual choice is a PNG of 180×180 pixels, with no transparency.
  • If you don't declare any icon, browsers automatically request /favicon.ico from the root of the site. For compatibility with old programs, some sites include it as well as the ones above.

Design tips: at 16 or 32 pixels, text can't be read. Use a simple, recognisable symbol (at The Blue Cup, the cup from the logo) with good contrast.

Other metadata: theme-color, author and generator

<meta name="theme-color" content="#1f4e79">
<meta name="author" content="The Blue Cup">
<meta name="generator" content="Visual Studio Code">
Metadata What it's for Do we use it?
theme-color Some mobile browsers colour the top bar with this colour Yes: the brand blue #1f4e79
author States the author of the document Optional; it can be the business
generator States the program that generated the page It is added automatically by content management systems (WordPress, site generators). On a hand-written page it adds nothing

theme-color supports the media attribute to use one colour with the light theme and another with the dark one; you will understand it when you see media queries in Media Queries.

Versions in other languages: hreflang (in passing)

If The Blue Cup ever had its website in Spanish and Catalan as well, each version would indicate its equivalents in the head:

<link rel="alternate" hreflang="en" href="https://thebluecup.example/">
<link rel="alternate" hreflang="es" href="https://thebluecup.example/es/">
<link rel="alternate" hreflang="ca" href="https://thebluecup.example/ca/">

That way, a search engine can show each user the version in their language. You already met the hreflang attribute on links (Special Links). Our website is only in English, so we won't use it.

Open Graph: cards when sharing

When you paste a link into WhatsApp, LinkedIn, Facebook or Telegram, a card appears with an image, a title and a description. That card is built from metadata defined by the Open Graph protocol (created by Facebook and adopted by almost every platform).

<meta property="og:type" content="website">
<meta property="og:site_name" content="The Blue Cup">
<meta property="og:title" content="The Blue Cup, neighbourhood café and bakery">
<meta property="og:description" content="Speciality coffee, pastries and freshly baked sourdough bread every day in Fictional Town.">
<meta property="og:url" content="https://thebluecup.example/">
<meta property="og:image" content="https://thebluecup.example/img/share.jpg">
<meta property="og:image:alt" content="The front of The Blue Cup with its blue awning and tables on the terrace">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:locale" content="en_GB">
  • Note that Open Graph uses the property attribute, not name.
Property What it indicates Guidelines
og:title Title of the card Can be like the title, without the brand if it's already in og:site_name
og:description Text of the card 1–2 sentences; can be the same as the description
og:image Image of the card Absolute URL; 1200×630 px is the most widely compatible size; JPEG or PNG
og:image:alt Alt text of the image Just like an alt
og:url Canonical address of the page Same as the canonical
og:type Type of content website for general pages, article for news
og:locale Language and country en_GB (with an underscore, not a hyphen)
og:site_name Name of the site The brand

Without Open Graph, each platform guesses: it takes the title, any old piece of text and the first image it finds (sometimes the tiny logo, or none at all). With Open Graph, you decide.

For a news item, og:type becomes article, and specific data can be added:

<meta property="og:type" content="article">
<meta property="article:published_time" content="2026-10-20T09:00:00+02:00">

X cards (Twitter Cards)

X (formerly Twitter) has its own set of metadata, with the twitter: prefix and the name attribute:

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="The Blue Cup, neighbourhood café and bakery">
<meta name="twitter:description" content="Speciality coffee, pastries and freshly baked sourdough bread every day.">
<meta name="twitter:image" content="https://thebluecup.example/img/share.jpg">
<meta name="twitter:image:alt" content="The front of The Blue Cup with its blue awning and tables on the terrace">
  • twitter:card is the only essential one: summary (small square image) or summary_large_image (large widescreen image).
  • If twitter:title, twitter:description or twitter:image are missing, X uses the Open Graph ones. So, in practice, it's enough to add twitter:card to a good Open Graph block.

How to preview and check the metadata

What you want to see How
title and icon In the browser tab, with Live Server
The whole head DevTools > Elements, expanding head
Approximate appearance in a search engine Online SERP preview tools: you paste the title and description and see how they are truncated
Social network cards Each platform's debugger (for example, Facebook's Sharing Debugger or LinkedIn's Post Inspector) and generic Open Graph previewers
Validity of the head HTML The validator from Validating HTML Code

An important limitation: social network debuggers need the page to be published on the Internet, because their servers have to download it. With Live Server (127.0.0.1) they can't see it. In the meantime, check the code in DevTools and, when you publish the site in Testing and Deployment, check the real cards.

Another detail: platforms cache the card for days. If you change the image and still see the old one, use the debugger's Scrape Again button.

meta keywords: why it's no longer any use

In many old tutorials you will see:

<meta name="keywords" content="coffee, café, bread, sourdough, croissant">

In the early days of the web, search engines used this list to find out what the page was about. It was soon full of abuse: pages that included hundreds of popular words that had nothing to do with their content. As a result, the major search engines have ignored it for many years (Google announced this publicly in 2009). Today they work out the topic from the actual content.

Writing it isn't a mistake, but it's wasted effort and it reveals to your competitors the words you are interested in. We won't use it.

Project: The Blue Cup's complete head

  1. The head of index.html

Replace the home page's head with this one:

  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>The Blue Cup, neighbourhood café and bakery</title>
    <meta name="description" content="Neighbourhood café and bakery in Fictional Town: speciality coffee, pastries and freshly baked sourdough bread every day. Open from 8:00 to 20:00.">
    <link rel="canonical" href="https://thebluecup.example/">

    <!-- Icons -->
    <link rel="icon" href="img/favicon.svg" type="image/svg+xml">
    <link rel="icon" href="img/favicon.png" sizes="32x32" type="image/png">
    <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
    <meta name="theme-color" content="#1f4e79">

    <!-- Open Graph -->
    <meta property="og:type" content="website">
    <meta property="og:site_name" content="The Blue Cup">
    <meta property="og:locale" content="en_GB">
    <meta property="og:title" content="The Blue Cup, neighbourhood café and bakery">
    <meta property="og:description" content="Speciality coffee, pastries and freshly baked sourdough bread every day in Fictional Town.">
    <meta property="og:url" content="https://thebluecup.example/">
    <meta property="og:image" content="https://thebluecup.example/img/share.jpg">
    <meta property="og:image:alt" content="The front of The Blue Cup with its blue awning and tables on the terrace">
    <meta property="og:image:width" content="1200">
    <meta property="og:image:height" content="630">

    <!-- X (Twitter) -->
    <meta name="twitter:card" content="summary_large_image">
  </head>

Explanation, block by block:

  • The essentials first: charset must be at the start (remember: within the first 1024 bytes); then viewport, title and description.
  • The home page title changes pattern: brand + what it is. The other pages keep "Page | The Blue Cup".
  • Canonical with an absolute URL and a trailing slash: the official address of the home page is the root of the domain, not /index.html.
  • Icons with relative paths. You will need three new files in img/: favicon.svg, favicon.png (32×32) and apple-touch-icon.png (180×180). You can create them from the logo; in Graphics in HTML: SVG and canvas you will draw a cup in SVG that will serve as the basis for the favicon.
  • Open Graph with absolute URLs. You will need img/share.jpg, 1200×630 pixels: for example, a widescreen crop of the front of the café.
  • X with just twitter:card: it takes the rest from Open Graph.
  • There is no meta robots (we want the page to be indexed normally), no keywords and no generator.
  • In Linking CSS to HTML you will add the stylesheet here.

Length of each value: the title has 43 characters and the description 146. Both are within the recommended ranges.

  1. The pattern for the other pages

Each page repeats the same structure, changing what makes it unique:

Page title og:type Canonical / og:url
menu.html Menu and prices | The Blue Cup website https://thebluecup.example/menu.html
bookings.html Book your table | The Blue Cup website https://thebluecup.example/bookings.html
gallery.html Gallery | The Blue Cup website https://thebluecup.example/gallery.html
news.html News | The Blue Cup website https://thebluecup.example/news.html
contact.html Contact | The Blue Cup website https://thebluecup.example/contact.html
privacy.html Privacy policy | The Blue Cup website https://thebluecup.example/privacy.html

For example, the variable part of the head of menu.html:

    <title>Menu and prices | The Blue Cup</title>
    <meta name="description" content="The Blue Cup's menu with prices and allergens: coffees, pastries, sourdough bread and a lunch menu from Monday to Friday for €9.50.">
    <link rel="canonical" href="https://thebluecup.example/menu.html">
    <!-- icons and theme-color: the same as in index.html -->
    <meta property="og:title" content="The Blue Cup's menu and prices">
    <meta property="og:description" content="Coffees, pastries, sourdough bread and a lunch menu.">
    <meta property="og:url" content="https://thebluecup.example/menu.html">
    <!-- og:type, og:site_name, og:locale, og:image and twitter:card: the same as in index.html -->
  • The provisional <style> block in menu.html stays where it is, at the end of the head, until module 8.
  • In privacy.html, which offers nothing to someone looking for a café, you can add <meta name="robots" content="noindex, follow">: it won't appear in the results, but search engines will still follow its links.
  • If in the future each news item had its own page, it would have og:type="article" and its publication date.

  1. Checking

  1. Open each page with Live Server and check the tab: the correct title and, if you already have the files, the icon.
  2. In DevTools > Elements, check that each page has its own title, its own description and its own canonical (it's very easy to copy a head and forget to change the canonical).
  3. Make a note in your Testing and Deployment to-do list: check the cards in the social network debuggers once the site is published.

Common Mistakes and Tips

  • Repeating the same title and the same description on every page. Each page needs its own.
  • Titles and descriptions that are too long, which get truncated in the results.
  • Relative paths in the canonical or in og:image: they must be absolute URLs.
  • Copying the head from one page to another without changing the canonical: you would be telling the search engine that every page is the home page.
  • Using name in Open Graph (<meta name="og:title">): the correct attribute is property.
  • A small or square Open Graph image when you want a large card: use 1200×630.
  • og:locale with a hyphen (en-GB): Open Graph uses an underscore, en_GB. (The lang attribute, on the other hand, uses a hyphen: en-GB.)
  • Believing that noindex protects a page: it only asks for it not to appear in the results; it is still public.
  • Wasting time on meta keywords.
  • Tip: write the description with the person deciding whether to click on your result in mind: what they will find and why it's of interest to them.

Exercises

Exercise 1. Find the mistakes in this head of gallery.html:

<head>
  <title>The Blue Cup | The Blue Cup | The Blue Cup</title>
  <meta charset="utf-8">
  <meta name="keywords" content="coffee, photos, gallery, café, croissant">
  <link rel="canonical" href="gallery.html">
  <meta name="og:image" content="img/share.jpg">
  <meta name="robots" content="index, follow">
</head>

Exercise 2. Write the title, the description and the Open Graph metadata for news.html. Decide on the og:type.

Exercise 3. The Blue Cup creates a thanks.html page that you reach after sending a booking. It must not appear in search engines. Write the part of its head that achieves this and explain whether it prevents anyone from seeing it.

Solutions

Solution 1.

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Gallery | The Blue Cup</title>
  <meta name="description" content="Photos of The Blue Cup's premises, pastries and bread, our intro video and the sound of the café.">
  <link rel="canonical" href="https://thebluecup.example/gallery.html">
  <meta property="og:image" content="https://thebluecup.example/img/share.jpg">
</head>
  • The charset must go at the start of the head.
  • The viewport was missing (a project convention since module 1).
  • The title repeated the brand and didn't describe the page.
  • The description was missing.
  • keywords is unnecessary: search engines ignore it.
  • The canonical must be an absolute URL.
  • Open Graph uses property, not name, and the image needs an absolute URL.
  • robots with index, follow isn't a mistake, but it's the default behaviour: it's unnecessary.
  • A complete head would also include the rest of the Open Graph block, twitter:card and the icons, following the project pattern.

Solution 2.

    <title>News | The Blue Cup</title>
    <meta name="description" content="The latest from The Blue Cup: seasonal coffees, sourdough bread-making workshops, recipes to try at home and the most ordered items each month.">
    <link rel="canonical" href="https://thebluecup.example/news.html">
    <meta property="og:type" content="website">
    <meta property="og:site_name" content="The Blue Cup">
    <meta property="og:locale" content="en_GB">
    <meta property="og:title" content="News from The Blue Cup">
    <meta property="og:description" content="Seasonal coffees, bread-making workshops, recipes and the latest from our bakery.">
    <meta property="og:url" content="https://thebluecup.example/news.html">
    <meta property="og:image" content="https://thebluecup.example/img/share.jpg">
    <meta property="og:image:alt" content="The front of The Blue Cup with its blue awning and tables on the terrace">
    <meta name="twitter:card" content="summary_large_image">
  • og:type is website: the page is a list of news items. It would be article if each news item had its own page.

Solution 3.

    <title>Booking received | The Blue Cup</title>
    <meta name="robots" content="noindex, nofollow">
  • noindex asks search engines not to show it in the results. nofollow is reasonable because the page doesn't offer any new links (although follow wouldn't be a mistake either).
  • It does not prevent anyone from seeing it: anyone with the address can open it. robots is a request to search engines, not a security measure.

Conclusion

You have gone through the head in depth. You know that the title must be unique, short and with the specific part first; that the description summarises the page for someone deciding whether to click on your result; that robots gives instructions to crawlers but protects nothing; and that the canonical URL avoids duplicate content and, like social network metadata, requires absolute addresses. You have added icons for the tab and the home screen and the brand colour with theme-color, and with Open Graph and twitter:card you control the card that appears when a link is shared. You also know that meta keywords is a thing of the past. The Blue Cup now has a complete head on the home page and a consistent pattern for the other pages. This metadata describes the page in general: its title, its summary, its image. But search engines can understand much more if you explain the content to them: that The Blue Cup is a café with a specific address, phone number and opening hours, or that the bread-making workshop is an event with a date, a time and a duration. In the next lesson, Microdata and Structured Data, you will learn to describe that information with the schema.org vocabulary so that search engines can show it in rich results.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved