AdvancedLesson 21 of 307 min read

HTML head, meta tags and on-page SEO basics

Control how search engines and browsers see your page with title, description, canonical, robots and other head elements.

In this lesson you will

  • Write titles and descriptions that earn clicks
  • Use charset, viewport, canonical and robots
  • Avoid costly noindex mistakes
  • Run a head checklist on every page

About 13 minutes

The part of the page nobody sees

Priya’s bakery site looks great, but when she searches her own shop name, the result shows a dull line of text and the title “Untitled Document”. Her competitor’s result has a clear title and an appetising description. The difference is not the visible page. It lives in the <head>, the part of the document visitors never see but browsers, search engines and social networks read first.

The essentials in every head

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Sourdough Bread in Lahore | Priya's Bakery</title>
  <meta name="description" content="Handmade sourdough, baked fresh each morning. Order online for pickup in Lahore.">
  <link rel="canonical" href="https://www.example.com/sourdough/">
  <link rel="icon" href="/favicon.ico">
</head>
  • charset says how the text is stored. Use UTF-8 and put it first, within the first 1,024 bytes of the file.
  • viewport makes phones show the page at their real width.
  • title is the clickable headline in search results and the text of the browser tab.
  • description is the summary search engines often show under the title.
  • canonical names the preferred address of the page when several addresses lead to the same content.
  • icon is the small image in the browser tab.

Writing a title that earns the click

The title is the single most important line you will write for a page. Aim for roughly 50 to 60 characters, since longer titles are cut off in results. Put the main topic first, then the brand. Make every title on the site unique, and make it describe that page, not the whole site.

Weak title Stronger title
Home Handmade sourdough in Lahore | Priya’s Bakery
Untitled Document Order a custom cake online | Priya’s Bakery

Descriptions that get read

A description does not directly raise your ranking, but a good one raises the number of people who click your result, and clicks matter. Write it as a short pitch of about 150 characters: what the page offers, for whom, and why to choose it. Search engines may rewrite it to match a query, which is normal.

Improve this head: add UTF-8 charset, the viewport tag, a descriptive title and a description of your choice.

<head>
  <title>Home</title>
</head>
<p>The head is invisible. Look at the browser tab, or view the page source, to see its effect.</p>

Add two meta tags first, then change the title text and add a meta description.

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Handmade sourdough in Lahore | Priya's Bakery</title>
  <meta name="description" content="Fresh sourdough and cakes baked every morning. Order online for pickup.">
</head>
<p>The head is invisible. Look at the browser tab, or view the page source, to see its effect.</p>

Robots: telling search engines what to do

Sometimes you do not want a page in search results, such as a thank-you page or a private test. The robots meta tag gives instructions.

<meta name="robots" content="noindex, follow">
  • noindex asks search engines not to list the page.
  • nofollow asks them not to follow its links.
  • index, follow is the default, so you do not need to write it.
Common mistake

A leftover noindex from a development version is a classic disaster. The site goes live and never appears in Google. Always check the head of your most important pages after launch.

Other useful head elements

  • <link rel="stylesheet" href="style.css"> loads your CSS.
  • <meta name="theme-color" content="#5A28C8"> tints the browser bar on phones.
  • <link rel="alternate" hreflang="fr" href="..."> points to the same page in another language.
  • <base href="..."> sets a starting address for relative links. Use it rarely, since it surprises people.
  • <script> loads JavaScript. You will learn where to place it in the performance lesson.

How search engines read your page

When a crawler visits a page it downloads the HTML, reads the head, then reads the visible content. It uses the title and headings to understand the topic, the links to find other pages, and the alt text to understand images. Everything you learned about semantic HTML is in effect your SEO foundation. The head simply adds the labels on the outside of the box.

Think of it like a book. The cover and back-cover blurb are the title and description. They do not change what is inside, but they decide whether anyone opens it.

A checklist for every new page

  1. Write a unique title under about 60 characters.
  2. Write a unique description around 150 characters.
  3. Check the charset and viewport tags are present.
  4. Add a canonical link if the page can be reached by more than one address.
  5. Make sure there is exactly one h1 that matches the title’s topic.
  6. View the page source and read the head with fresh eyes.

Add a robots tag so this thank-you page is not indexed, and a theme colour of #5A28C8.

<head>
  <meta charset="UTF-8">
  <title>Thank you | Priya's Bakery</title>
</head>
<p>The head is invisible. Look at the browser tab, or view the page source, to see its effect.</p>

Both are meta tags: name=”robots” content=”noindex” and name=”theme-color”.

<head>
  <meta charset="UTF-8">
  <title>Thank you | Priya's Bakery</title>
  <meta name="robots" content="noindex">
  <meta name="theme-color" content="#5A28C8">
</head>
<p>The head is invisible. Look at the browser tab, or view the page source, to see its effect.</p>
Do not stuff keywords

Repeating a phrase ten times in the title or description does not help. Search engines read natural language, and visitors scroll past spammy results.

Reading someone else’s head

One of the best ways to learn is to look at what successful sites do. Open any site you admire, right-click and choose View Page Source, then press Ctrl+F and search for <title. Within a minute you will see their title, description, social tags and often their structured data. Do this for three sites and write down what they have in common. You will notice that the best ones are consistent: every page has a unique, tidy head, and the same pattern repeats across the whole site.

Notice too what they leave out. You will almost never see the old keywords tag, and rarely any tag that does nothing. A short, careful head beats a long, messy one.

Titles for different kinds of pages

  • Homepage: brand plus what you do, such as “Priya’s Bakery | Handmade bread and cakes in Lahore”.
  • Product or service page: the thing first, then the brand: “Custom birthday cakes | Priya’s Bakery”.
  • Blog post: the actual headline, trimmed to fit: “How to feed a sourdough starter | Priya’s Bakery”.
  • Contact page: include the place: “Contact and opening hours in Lahore | Priya’s Bakery”.

Check what you learned

Five quick questions. Pick an answer and you will see straight away whether it is right and why.

Which element sets the clickable headline in search results?

  1. <h1>
  2. <title>
  3. <header>
  4. <meta charset>

The title element is the headline shown in results and browser tabs.

About how long should a title be?

  1. Around 5 characters
  2. Around 50 to 60 characters
  3. Over 200 characters
  4. It does not matter

Longer titles are truncated in search results.

What does noindex do?

  1. Hides the page from visitors
  2. Asks search engines not to list the page
  3. Speeds up the page
  4. Deletes the page

noindex only affects search listings. Visitors can still open the page.

Why use a canonical link?

  1. To style the page
  2. To name the preferred address when several lead to the same content
  3. To add a favicon
  4. To block ads

It prevents duplicate-content confusion.

What is the best use of the description?

  1. Stuffing keywords
  2. A short, honest pitch that earns the click
  3. Leaving it blank
  4. Copying the title

A good description raises the number of people who click your result.

Summary

  • The head is read first by browsers and search engines.
  • Unique titles and descriptions help every page.
  • Use canonical and robots to guide search engines.
  • Always check the head after launch.

Next lesson

Next: make your pages look great when they are shared on social networks.

Questions

Do meta descriptions affect ranking?

Not directly, but good ones increase clicks, which is valuable. Search engines may also rewrite them to match the search.

Do I still need the keywords meta tag?

No. Search engines ignore it, so leave it out.

Where is the head in WordPress?

A theme and your SEO plugin output it. This lesson helps you understand what they generate.

Progress is saved in this browser.