HTML Metadata
Meta tags, Open Graph, Twitter cards, structured data, and SEO.
Overview
Metadata provides information about the document to browsers and search engines.
Key Concepts
- Viewport — Mobile-friendly configuration
- Open Graph — Social media sharing
- Twitter Cards — Twitter-specific metadata
- Structured Data — JSON-LD for rich snippets
- Favicon — Browser tab icon
Code Examples
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SEO -->
<title>Page Title | Site Name</title>
<meta name="description" content="Page description for search engines">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://example.com/page">
<!-- Open Graph -->
<meta property="og:title" content="Page Title">
<meta property="og:description" content="Page description">
<meta property="og:image" content="https://example.com/image.jpg">
<meta property="og:url" content="https://example.com/page">
<meta property="og:type" content="website">
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description">
<meta name="twitter:image" content="https://example.com/image.jpg">
<!-- Favicon -->
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/manifest.json">
<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "Page Title",
"description": "Page description",
"url": "https://example.com/page"
}
</script>
</head>
<body>
<!-- Content -->
</body>
</html>
Practice
Create a complete metadata setup for a blog post with structured data.