SEO Basics
Improve search rankings with meta tags, semantic HTML, sitemaps, and structured data.
What you'll learn
- How search engines crawl, index, and rank web pages
- Essential meta tags: title, description, Open Graph, canonical
- How semantic HTML and heading hierarchy signal content structure
- Structured data (Schema.org), sitemaps, and robots.txt for crawlers
Concept
SEO Basics
SEO (Search Engine Optimization) is the practice of making your web pages rank well in search engines like Google. Good SEO means when someone searches for what your page offers, they find it. SEO is part technical (how you structure your HTML and metadata), part content (what you write), and part authority (who links to you). This lesson covers the technical fundamentals every web developer must know.
How Search Engines Work
Search engines do three things: crawl (follow links to discover pages), index (store and understand the content), and rank (order results by relevance and quality). Your job is to make crawling easy, your content understandable, and your pages fast and accessible. If a search engine cannot crawl your page or understand its content, it cannot rank it — no matter how good the content is.
Essential Meta Tags
The <head> of your HTML carries metadata that search engines and social media read:
<title>— the most important on-page SEO signal. Unique, descriptive, under 60 characters.<meta name="description">— the snippet shown in search results. Under 155 characters, compelling, unique per page.<link rel="canonical">— tells search engines the preferred URL when duplicate content exists.- Open Graph tags (
og:title,og:description,og:image) — control how your page looks when shared on social media.
Semantic HTML and Headings
Search engines use your HTML structure to understand content. Use one <h1> per page (the main topic), followed by <h2>s for sections, <h3>s for sub-sections — a logical, nested hierarchy. Use semantic tags (<article>, <nav>, <main>) so the crawler can identify what is navigation vs. content. A page full of <div>s tells the search engine nothing about the content's structure.
Structured Data (Schema.org)
Structured data uses a vocabulary called Schema.org to tell search engines exactly what your content is — a recipe, a product, a review, an event. You add it as JSON-LD in a <script type="application/ld+json"> tag. This enables rich results in search — star ratings, prices, event dates shown directly in the search listing. It does not directly improve ranking, but it improves click-through rate by making your result more attractive.
Sitemaps and robots.txt
A sitemap.xml lists all your pages, helping search engines discover them. A robots.txt tells crawlers what they may and may not crawl. Submit your sitemap in Google Search Console. For large sites, a sitemap is essential; for small sites, good internal linking may suffice, but a sitemap never hurts.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Chocolate Chip Cookie Recipe — Easy & Chewy</title>
<meta name="description"
content="Classic chocolate chip cookies in 30 minutes.
Chewy centers, crisp edges, no mixer needed." />
<link rel="canonical" href="https://example.com/recipes/chocolate-chip-cookies" />
<!-- Open Graph for social sharing -->
<meta property="og:title" content="Chocolate Chip Cookie Recipe" />
<meta property="og:image" content="https://example.com/img/cookies.jpg" />
<meta property="og:type" content="article" />
<!-- Structured data for rich results -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Recipe",
"name": "Chocolate Chip Cookies",
"cookTime": "PT30M",
"recipeYield": "24 cookies",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "342"
}
}
</script>
</head>
<body>
<main>
<article>
<h1>Chocolate Chip Cookies</h1>
<p>Classic, chewy, and ready in 30 minutes.</p>
</article>
</main>
</body>
</html>
The title and description are unique and compelling. canonical prevents duplicate-content issues. Open Graph tags control social sharing appearance. The JSON-LD structured data tells search engines this is a Recipe with a rating, enabling rich results. The h1 clearly states the page's topic.
Try it
- HTML ↔ Markdown
Check that your SEO-optimized HTML converts cleanly to Markdown for content reuse.
- Markdown Previewer
Preview your content to verify heading structure and readability for SEO.
Common mistakes
The mistake
Using the same <title> and meta description on every page.
The fix
Every page needs a unique, descriptive title (under 60 chars) and meta description (under 155 chars). The title is the strongest on-page SEO signal. Duplicate titles tell search engines your pages are the same.
The mistake
Using multiple <h1> tags or skipping heading levels (h1 to h3 with no h2).
The fix
Use exactly one <h1> per page as the main topic. Follow a logical, nested hierarchy: h1 > h2 > h3. Do not skip levels. Search engines and screen readers both rely on this structure to understand content.
Related Resources
Related Cheatsheets
- HTML Cheatsheet
Reference for meta tags, semantic structure, and SEO-friendly markup.
Practice SEO Basics
4 exercises
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.