SEO ensures your site is discoverable and understandable by search engines. Good SEO starts with clean HTML and the right tags.
HTML SEO (Search Engine Optimization)
1) Title & Meta Description
<title>Learn HTML SEO | Codingwithsonu</title>
<meta name="description"
content="SEO basics: titles, descriptions, canonical, headings, alt text.">
- Unique
<title>for every page (50–60 characters). meta descriptionaround 150–160 characters.
2) Headings Structure
<h1>HTML SEO Guide</h1>
<h2>Meta Tags</h2>
<h3>Title & Description</h3>
Use one <h1> per page, then h2, h3 hierarchically.
3) Canonical & Robots
<link rel="canonical"
href="https://codingwithsonu.com/html/html-seo.php">
<meta name="robots" content="index, follow">
Canonical prevents duplicate content issues; robots control indexing.
4) Image SEO
<img src="html-seo.png"
alt="Diagram of HTML SEO tags"
width=600 height=400>
- Always add descriptive
alttext. - Define
widthandheightto reduce layout shift.
5) Link Best Practices
<a href="/html/html-basics.php">Learn HTML Basics</a>
- Use descriptive anchor text (avoid “Click here”).
- Internal links help search engines crawl content.
6) Structured Data (JSON-LD)
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "HTML SEO Basics",
"author": "Sonu Kumar Pandit",
"publisher": {
"@type": "Organization",
"name": "Codingwithsonu"
}
}
</script>
Structured data helps enhance search results with rich snippets.
7) Social Sharing Tags
<!-- Open Graph -->
<meta property="og:title" content="HTML SEO Basics">
<meta property="og:description" content="Learn HTML SEO best practices">
<meta property="og:image" content="seo.png">
<!-- Twitter Cards -->
<meta name="twitter:card" content="summary_large_image">
8) Sitemap & Robots.txt
Sitemap: https://codingwithsonu.com/sitemap.xml
User-agent: *
Allow: /
Add sitemap.xml in your site root and reference it in robots.txt.
SEO Checklist:
- Unique
<title>andmeta descriptionfor each page. - Logical heading structure (H1 → H2 → H3).
- Canonical URLs to prevent duplicate content.
- Descriptive alt text for images.
- Clean, descriptive, keyword-friendly URLs.
- Structured data (JSON-LD) for articles/products.
- Open Graph + Twitter tags for social sharing.
- Sitemap.xml & Robots.txt configured correctly.