Skip to the content

Lesson 14 of 296

Meta tags and SEO basics

What you will learn

  • What goes in the head of a page
  • What SEO is
  • The meta tags every page needs
  • How links look when shared on social media
  • How search engines find your pages
  • How to connect CSS and JavaScript files
On this page

The head of a page

The <head> holds information about the page. Most of it is not shown on the page, but it controls how the page looks in browser tabs, search results and social media shares.

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Plumbing Services in Leeds | Acme Plumbing</title>
  <meta name="description" content="24-hour emergency plumbers in Leeds. Fixed prices, no call-out fee. Call 0113 496 0000.">
  <link rel="canonical" href="https://acmeplumbing.co.uk/leeds">
  <link rel="icon" href="/favicon.ico">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/app.js" defer></script>
</head>

What is SEO?

SEO (Search Engine Optimisation) means making pages easy for search engines like Google to find, understand and show in their results. Good SEO brings visitors without paying for adverts.

Search engines use programs called crawlers that visit pages, follow links and read the HTML. Then they decide which pages to show for each search.

The title tag

The most important tag for SEO. It is shown in the browser tab and as the blue clickable line in Google.

Good titles:

  • are unique for every page
  • put the most important words first
  • are about 50 to 60 characters, because longer titles get cut off in results
  • often end with the brand name
<title>Plumbing Services in Leeds | Acme Plumbing</title>

The meta description

A short summary of the page. Google often shows it under the title in results. It does not directly change ranking, but a good description makes more people click.

  • Unique for every page
  • About 150 to 160 characters
  • Says clearly what the page offers

The viewport and charset tags

These are covered in Lesson 7. Every page needs both.

Canonical URL

Sometimes the same page can be reached by more than one URL, for example with and without ?ref=email at the end. Search engines may treat these as copies. The canonical tag says which URL is the real one.

<link rel="canonical" href="https://acmeplumbing.co.uk/leeds">

The robots meta tag

Tells search engines whether to show the page in results.

<meta name="robots" content="noindex">

Use noindex for pages that should not appear in Google, such as thank-you pages or admin pages.

Social media sharing: Open Graph

When someone shares your link on Facebook, LinkedIn or WhatsApp, the preview card (title, image, description) comes from Open Graph tags.

<meta property="og:title" content="Plumbing Services in Leeds">
<meta property="og:description" content="24-hour emergency plumbers. Fixed prices.">
<meta property="og:image" content="https://acmeplumbing.co.uk/images/share.jpg">
<meta property="og:url" content="https://acmeplumbing.co.uk/leeds">
<meta property="og:type" content="website">

X (Twitter) also reads its own tags, such as <meta name="twitter:card" content="summary_large_image">, and uses the Open Graph tags when its own are missing. A common share image size is 1200 by 630 pixels.

How search engines find your pages

File / toolWhat it does
sitemap.xmlA list of all the pages you want search engines to find
robots.txtA file at the root of the site that tells crawlers which areas they should not visit
Google Search ConsoleA free Google tool to submit your sitemap and see search problems

robots.txt is a request, not a lock. It does not protect private pages. Private pages need a login.

On-page SEO basics

  • One clear <h1> that matches the topic of the page.
  • Headings in order (Lesson 8).
  • Semantic HTML (Lesson 12).
  • Descriptive link text and alt text.
  • Clean, readable URLs: /services/boiler-repair, not /page?id=4821.
  • Fast pages. Google measures speed and stability with Core Web Vitals. Slow pages rank lower.
  • Mobile friendly. Google mainly uses the mobile version of a page to rank it.

Structured data

Structured data is extra information in a standard format (called schema.org) that tells Google exactly what a page is about: a business, a product, a recipe, an event. It can make results show stars, prices or opening hours. It is usually written in a <script type="application/ld+json"> tag.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "Acme Plumbing",
  "telephone": "+44 113 496 0000"
}
</script>

Connecting CSS and JavaScript

<link rel="stylesheet" href="/css/style.css">
<script src="/js/app.js" defer></script>

CSS goes in the <head>, so the page is styled before it appears.

JavaScript is different. When the browser meets a normal <script>, it stops building the page until the script is downloaded and run. This makes the page slower to appear. There are three ways to load a script:

HowWhat happensUse for
<script src="...">Stops building the page, downloads and runs at onceRarely needed now
<script src="..." async>Downloads while the page builds, then runs as soon as it arrives, in any orderIndependent scripts, such as analytics
<script src="..." defer>Downloads while the page builds, then runs after the page is fully read, in orderMost of your own scripts

defer vs async is a common interview question. In short: defer keeps the order and waits for the HTML; async runs as soon as it is ready, in any order.

Common mistakes

  • The same title on every page.
  • Missing meta description.
  • Missing Open Graph image, so shared links look plain.
  • Marking the whole site noindex by accident after launch.
  • Thinking robots.txt hides private data.
  • Loading scripts in the head without defer or async, which slows the page.

How to say it in an interview

"The head holds the page's metadata: charset, viewport, a unique title and meta description, the canonical URL, Open Graph tags for social sharing, and links to CSS and scripts. For SEO I use semantic HTML with one h1, clean URLs, a sitemap, and I keep pages fast and mobile friendly because Core Web Vitals affect ranking. I load scripts with defer so they do not block the page, or async for independent scripts like analytics."

Key words

WordMeaning
MetadataInformation about the page itself
SEOMaking pages easy for search engines to find and rank
CrawlerA program that visits and reads web pages for a search engine
Meta descriptionA short summary shown in search results
Canonical URLThe official URL of a page when there are copies
Open GraphTags that control how links look when shared
SitemapA file listing the pages of a site
robots.txtA file asking crawlers not to visit certain areas
defer / asyncWays to load scripts without blocking the page
Core Web VitalsGoogle's measures of page speed and stability

Now prove it

This lesson is complete when you pass the quiz and all three practice levels.