SEO and meta tags
SEO (Search Engine Optimization) is about helping search engines find, understand and rank your pages. Much of it starts in your HTML: the <head>, your headings, links and structure.
The essential <head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 1. Title: the most important on-page SEO element (~50–60 characters) -->
<title>Learn SQL Joins with Examples | Learn to Code</title>
<!-- 2. Description: shown under the title in search results (~150–160 characters) -->
<meta name="description" content="Understand INNER, LEFT and FULL joins with interactive examples you can run in your browser. Free, beginner friendly.">
<!-- 3. Canonical: the one "official" URL for this content -->
<link rel="canonical" href="https://learntocode.example/learn/sql/joins">
<!-- 4. Icons -->
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
</head>Writing good titles and descriptions
- Unique for every page: duplicate titles confuse search engines.
- Front-load keywords people actually search for: "Learn SQL Joins" beats "Lesson 6".
- Write for humans. The title and description are your advert in the search results, and their job is to earn the click.
Social sharing: Open Graph and Twitter cards
These control the preview card when someone shares your link on WhatsApp, LinkedIn, X, Slack and so on.
<meta property="og:type" content="article">
<meta property="og:title" content="Learn SQL Joins with Examples">
<meta property="og:description" content="Interactive SQL joins tutorial.">
<meta property="og:image" content="https://learntocode.example/og/sql-joins.png"> <!-- 1200×630 -->
<meta property="og:url" content="https://learntocode.example/learn/sql/joins">
<meta name="twitter:card" content="summary_large_image">Controlling indexing
<meta name="robots" content="noindex, nofollow"> <!-- keep this page out of search results -->Use it for staging sites, thank-you pages and internal search results. Site-wide rules go in /robots.txt:
User-agent: *
Disallow: /admin/
Sitemap: https://learntocode.example/sitemap.xmlA sitemap.xml lists all your pages so crawlers can discover them.
Structured data (JSON-LD)
Structured data describes your content in a machine-readable way. It can earn rich results: star ratings, FAQs, recipe cards and course listings in search.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Course",
"name": "SQL from scratch to pro",
"description": "Interactive SQL course with live examples.",
"provider": { "@type": "Organization", "name": "Learn to Code" }
}
</script>Test it with Google's Rich Results Test.
On-page SEO checklist
- One
<h1>that describes the page, with a logicalh2/h3structure. - Descriptive URLs:
/learn/sql/joinsbeats/page?id=123. - Internal links with meaningful anchor text.
- Alt text on images.
- Fast and mobile-friendly: Google ranks the mobile version of your site, and speed (Core Web Vitals) matters.
- HTTPS everywhere.
- Great content that answers the searcher's question better than anything else. No meta tag beats this.
The
keywordsmeta tag (<meta name="keywords">) has been ignored by Google for over a decade. Don't bother.
Single-page apps and SEO
Sites rendered entirely by JavaScript (like a plain React app) can be slower for search engines to index, and every page may share the same <title>. Solutions:
- Update
document.titleand the meta tags on each route. - Use server-side rendering or static generation (Next.js, Astro, Remix) so every URL serves full HTML.
Practice
Write a complete <head> for a page about "Docker Compose tutorial for beginners" on a site of your choice. Include the title, description, canonical URL, Open Graph tags and JSON-LD with @type: "Article".
1.Which element most strongly influences how a page appears in search results?
2.What is rel="canonical" for?