SEO Basics for Frontend Developers

Beginner · 3 min

The markup-level SEO a frontend developer actually controls — meta tags, heading hierarchy, canonical URLs, sitemaps, and robots.txt.

Before thisSemantic HTML & Document Structure

Fireship · 3 min

SEO Basics for Frontend Developers

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by FireshipReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Technical SEO — the part a frontend developer controls — is markup and infrastructure; content strategy and keyword research are a different job entirely.
  • A crawler reads your HTML roughly the way a screen reader does: it needs real heading hierarchy and semantic structure, not just visually styled text, to understand what a page is about.
  • The <title> and meta description tags are what a search engine typically shows in results, so they deserve the same care as the page's actual headline.
  • A canonical URL tells a search engine which version of a page is the 'real' one when several URLs can serve the same or near-identical content, preventing duplicate-content penalties.
  • sitemap.xml tells crawlers what pages exist and robots.txt tells them what not to bother crawling — two small files that control a crawler's behavior before it even renders a page.

Two very different jobs under one name

“SEO” covers two genuinely separate disciplines that get flattened into one term. One is content strategy: figuring out what topics to write about, which search terms people actually use, how to structure an article so it answers the question someone typed. That’s a content and marketing job, and it lives almost entirely outside a codebase. The other is technical SEO: making sure the markup, structure, and infrastructure of a site don’t actively prevent a search engine from understanding and indexing it correctly. That’s a frontend developer’s job, and it’s what this lesson covers. The embedded video above runs under three minutes and is a fast, accurate overview of the technical side — but given how little ground 170 seconds can cover, most of the actual teaching here, especially on canonical URLs and the two crawler-control files, is in this written material rather than the clip.

How a crawler actually sees your page

A search engine’s crawler fetches your HTML (and for most major crawlers today, executes your JavaScript too, though that process is slower and less reliable than parsing plain HTML up front) and tries to extract structure and meaning from it — not unlike how a screen reader builds a navigable outline from the same markup. This is the real link between semantic HTML and SEO: a crawler uses your heading hierarchy, your semantic landmarks, and your alt text as signals for what the page is actually about. A page that’s visually a perfect headline rendered as a styled <div> with CSS font-size: 2rem gives a crawler nothing to grab — there’s no <h1> telling it “this is the title.” The fix is the same fix as for accessibility: use the tag whose job matches the content, not just the tag that happens to render the way you want.

Heading hierarchy specifically matters beyond having an <h1> at all. One <h1> per page, with <h2>s for its major sections and <h3>s nested under the relevant <h2>, builds an outline a crawler can parse the same way a table of contents works for a reader. Skipping levels, or using heading tags purely because they’re a convenient way to get bold large text, muddies that signal.

Title and meta description

Two tags in <head> do more for search visibility than almost anything else on the page:

<title>Affordable Running Shoes for Beginners | YourStore</title>
<meta name="description" content="Compare beginner-friendly running shoes under $80, with sizing guidance and return policy details.">

The <title> is typically the clickable headline a search engine shows in results, and it’s also what shows in a browser tab. The description is typically the snippet of text shown underneath that headline — search engines don’t always use it verbatim, but a well-written one improves click-through even when it doesn’t change ranking directly. Both deserve the same editorial attention as the page’s visible headline, because for a lot of users, this is the only part of your page they’ll see before deciding whether to click.

Canonical URLs: solving duplicate content

A single piece of content frequently ends up reachable at more than one URL. A product might be reachable at /shoes/trail-runner-200 and also at /shoes/trail-runner-200?ref=homepage&color=blue for the same underlying page. A blog might serve the same article at both /blog/post-title and /blog/post-title/ with a trailing slash. To a search engine, these can look like separate pages with identical or near-identical content — which risks splitting ranking signal between them, or worse, the engine deciding one of them is spam-like duplicate content.

The <link rel="canonical"> tag in <head> fixes this by explicitly declaring which URL is the authoritative one:

<link rel="canonical" href="https://yourstore.com/shoes/trail-runner-200">

Every variant of the page — with query parameters, with a different casing, with or without a trailing slash — should point its canonical tag at the one URL you actually want indexed. This is one of the parts of technical SEO the embedded video doesn’t have time to cover, and it’s also one of the parts most commonly missed by teams who otherwise do everything else right: an e-commerce site with filter and sort parameters in the URL can accidentally generate thousands of near-duplicate indexable pages without a canonical tag reining them back to one.

sitemap.xml and robots.txt: talking to the crawler directly

Two plain-text files, both conventionally placed at the root of a domain, control a crawler’s behavior before it has rendered a single page:

sitemap.xml is a machine-readable list of URLs on your site that you want indexed, often with metadata like when each was last updated. It’s a positive signal — “here’s what exists, please consider crawling it” — and it’s especially useful for a large site, or a site with pages that aren’t easily discoverable by following links alone (a product catalog with thousands of pages, for instance).

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>https://yourstore.com/</loc></url>
  <url><loc>https://yourstore.com/shoes/trail-runner-200</loc></url>
</urlset>

robots.txt is the inverse: rules telling crawlers which paths they should not bother crawling at all — an admin panel, an internal search results page, a staging environment that accidentally went public. It’s a plain-text file with simple directives:

User-agent: *
Disallow: /admin/
Disallow: /internal-search

Sitemap: https://yourstore.com/sitemap.xml

It’s worth being precise about what robots.txt actually does: it’s a request that well-behaved crawlers honor, not an access-control mechanism. It won’t stop a page from being indexed if something else links to it, and it does nothing to prevent a human from visiting the URL directly — it’s a courtesy convention for crawlers, not a security boundary. Keeping something truly private requires authentication, not a disallow rule.

Together, these two files and the canonical tag are the infrastructure layer of technical SEO: they don’t make your content better, but they make sure a crawler correctly understands what exists, what’s authoritative, and what to leave alone — which is the precondition for any of the content-strategy work to matter at all.

Check yourself

  1. 01What's the difference between the technical SEO this lesson covers and the content-strategy side of SEO?

    Technical SEO is markup and infrastructure a developer controls directly — tags, structure, canonical URLs, sitemaps — while content strategy is about what to write about and which keywords to target, a discipline that lives outside the codebase entirely.

  2. 02Why does heading hierarchy (h1, then h2s, then h3s under them) matter for SEO, not just visual style?

    A crawler uses heading levels to infer a page's topic structure the same way a screen reader uses them for navigation, so skipping levels or using headings purely for their font size rather than their outline position confuses a signal search engines rely on.

  3. 03When would you need a canonical URL, and what problem does it solve?

    When the same or near-identical content is reachable at more than one URL — like a product page reachable with and without a tracking query parameter — a canonical tag tells search engines which URL is the authoritative one to index, preventing them from treating the variants as duplicate content and splitting ranking signal between them.

  4. 04What's the functional difference between sitemap.xml and robots.txt?

    sitemap.xml is a positive list telling crawlers which URLs exist and should be considered for indexing, while robots.txt is a set of rules telling crawlers which paths they should not crawl at all — one invites attention, the other withholds it.

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark