← Back to Chapters

SEO Tags in HTML

? SEO Tags in HTML

⚡ Quick Overview

SEO (Search Engine Optimization) helps search engines understand and present your pages. In HTML, several tags inside the <head> section influence how your page appears in search results and when shared on social media. This guide focuses on the essential tags you’ll set on nearly every page and avoids outdated practices.

You’ll learn how to use the title, meta description, canonical URL, robots meta tag, social preview tags (Open Graph & Twitter), and structured data (JSON-LD) in a clean, modern way.

? Key Concepts

  • <title> – The main headline for search results and browser tabs.
  • Meta description – A short summary that may appear as the search snippet.
  • Canonical – Declares the preferred URL when you have duplicates or variants.
  • Meta robots – Controls indexing and crawling behavior (index/noindex, follow/nofollow).
  • Open Graph & Twitter Cards – Control how your page looks when shared on social media.
  • Structured data (JSON-LD) – Optional, but can enable rich results (Article, Product, Breadcrumb, etc.).
  • Deprecated: meta keywords – Modern search engines ignore it; don’t use it.

? Syntax & Theory

Most SEO tags live inside the <head> of your document. You typically:

  • Set a unique, descriptive title per page.
  • Add a meta description that “pitches” the content to searchers.
  • Provide a canonical link for duplicate/variant URLs.
  • Use robots meta to hide or expose pages when needed.
  • Configure Open Graph and Twitter tags for better link previews.
  • Optionally add JSON-LD structured data describing the page type.

? Head SEO Starter Template

? View <head> Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>Learn SEO Tags – Beginner Tutorial</title> <!-- ~50–60 chars, unique per page -->

  <meta name="description"
        content="Beginner-friendly guide to essential SEO tags: title,
        meta description, canonical, robots, social cards, and JSON-LD." />

  <link rel="canonical" href="https://www.example.com/seo-tags-tutorial" /> <!-- Absolute URL -->

  <meta name="robots" content="index, follow" /> <!-- Or noindex,follow on thin/private pages -->

  <!-- Social share previews (Open Graph / Twitter) -->
  <meta property="og:type" content="article" />
  <meta property="og:title" content="Learn SEO Tags – Beginner Tutorial" />
  <meta property="og:description" content="Beginner-friendly guide to essential SEO tags." />
  <meta property="og:url" content="https://www.example.com/seo-tags-tutorial" />
  <meta property="og:image" content="https://www.example.com/assets/seo-cover.jpg" />

  <meta name="twitter:card" content="summary_large_image" />
  <meta name="twitter:title" content="Learn SEO Tags – Beginner Tutorial" />
  <meta name="twitter:description" content="Beginner-friendly guide to essential SEO tags." />
  <meta name="twitter:image" content="https://www.example.com/assets/seo-cover.jpg" />
</head>
<body>...</body>
</html>

? Robots Meta Quick Reference

? View Robots Examples
<meta name="robots" content="index, follow" /> <!-- default: index page and crawl links -->
<meta name="robots" content="noindex, follow" /> <!-- hide page, still crawl links -->
<meta name="robots" content="noindex, nofollow" /> <!-- hide page and links -->
<meta name="robots" content="max-snippet:-1, max-image-preview:large" /> <!-- control snippet length and image preview size -->

? Canonical Best Practices

  • Use one canonical per page, pointing to the preferred absolute URL.
  • Self-canonicalize normal pages to themselves.
  • Only canonicalize pages that are near-identical (UTM variants, filtered duplicates, print views).
  • Avoid combining noindex with a canonical to a different URL—send a clear, consistent signal.

? Structured Data (JSON-LD) Example

Use JSON-LD to describe your content for search engines. This doesn’t directly boost rankings, but it can unlock rich snippets such as article cards, breadcrumbs, product info, and more. The snippet below shows an Article schema.

? View JSON-LD Example
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Learn SEO Tags – Beginner Tutorial",
  "description": "Beginner-friendly guide to essential SEO tags.",
  "author": { "@type": "Person", "name": "Alex" },
  "datePublished": "2025-01-10",
  "image": ["https://www.example.com/assets/seo-cover.jpg"],
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://www.example.com/seo-tags-tutorial"
  }
}
</script>

? Live Output / Explanation

?️ What This Configuration Sets

Title: Learn SEO Tags – Beginner Tutorial

Meta Description: Beginner-friendly guide to essential SEO tags: title, meta description, canonical, robots, social cards, and JSON-LD.

Canonical URL: https://www.example.com/seo-tags-tutorial

Robots: index, follow

OG/Twitter image: https://www.example.com/assets/seo-cover.jpg

Note: We intentionally omit meta keywords because it is obsolete for modern search engines.

? Tips & Best Practices

  • Keep titles unique and descriptive (~50–60 characters). Front-load the most important words.
  • Write meta descriptions for humans (around 150–160 characters). Treat them like an ad-style pitch.
  • Use absolute URLs for canonical links and Open Graph image URLs.
  • Add lang on the <html> element; use hreflang for multi-language sites.
  • Ensure important pages aren’t blocked by robots.txt or accidental noindex.
  • Test with tools: Rich Results Test, URL Inspection in Search Console, and social debuggers (Facebook/Twitter).
  • Avoid empty or duplicate titles and descriptions across many pages.
  • Don’t use meta keywords or stuff keywords in titles/descriptions.
  • Make sure there is only one clear canonical per page, and avoid conflicting signals.
  • Always include social tags for key pages so shares look clean and clickable.

? Try It Yourself

  • Write a unique title and meta description for your homepage and one product/article page.
  • Add proper Open Graph/Twitter tags to a page and verify them using social debuggers.
  • Implement a self-canonical on a normal page, and canonicalize a UTM-variant URL to it.
  • Add Article or Breadcrumb JSON-LD to a sample page and validate with Google’s Rich Results Test.
  • Create a staging-environment banner reminding you to set noindex on non-production sites.

? Summary

  • SEO-relevant tags live mainly in the <head> section of your HTML.
  • Use meaningful titles, human-friendly meta descriptions, and a single, correct canonical URL per page.
  • Configure robots meta only when you need to control indexing or following behavior.
  • Open Graph and Twitter tags improve how your pages look when shared on social networks.
  • JSON-LD structured data helps search engines understand your content and can unlock rich results.
  • Ignore meta keywords and avoid conflicting settings like multiple canonicals or accidental noindex.