Skip to content

Meta Tags and Open Graph: The Complete SEO Guide for Developers

Meta tags are HTML elements that provide metadata about your web page to search engines and social platforms. The right meta tags improve your search rankings, click-through rates and how your content appears when shared on social media. Getting them wrong means your pages look broken in search results and generate fewer clicks.

Essential Meta Tags for SEO

These are the meta tags that every page should have:

Title Tag

The title tag is the single most important on-page SEO element. It appears in search results, browser tabs, and social shares:

<title>CSS Flexbox Guide - codetools.run</title>
  • Keep it under 60 characters so it does not get truncated in search results.
  • Put the primary keyword near the beginning.
  • Make each page title unique across your site.
  • Include your brand name at the end, separated by a dash or pipe.

Meta Description

The meta description appears below the title in search results. Google does not use it as a ranking factor, but a well-written description significantly improves click-through rate:

<meta name="description" content="Learn CSS Flexbox from scratch with practical examples." />
  • Keep it between 120-160 characters.
  • Write it like ad copy. Summarize the value, not just the topic.
  • Include a call to action when appropriate.
  • Each page needs a unique description.

Canonical URL

The canonical tag tells search engines which URL is the primary version of a page. This prevents duplicate content issues when the same page is accessible via multiple URLs:

<link rel="canonical" href="https://example.com/page/" />

Open Graph Tags

Open Graph (OG) tags control how your page appears when shared on Facebook, LinkedIn, Discord and most other platforms. Without OG tags, these platforms try to guess your content, often with poor results.

<meta property="og:title" content="Page Title" />

<meta property="og:description" content="Page description here." />

<meta property="og:image" content="https://example.com/image.png" />

<meta property="og:url" content="https://example.com/page/" />

<meta property="og:type" content="article" />

og:image Best Practices

The OG image is the most impactful Open Graph tag. A good social image can double your click-through rate:

  • Use 1200x630 pixels. This is the recommended size for Facebook and LinkedIn. It also works well on Twitter.
  • Use PNG or JPG format. SVG is not supported by social media crawlers.
  • Keep file size under 1 MB. Large images may not load when platforms fetch your page.
  • Always use absolute URLs. Relative paths do not work with social media crawlers.
  • Add text to your image. Include the page title or a key message directly on the image so it is visible in the preview card.

Twitter Card Tags

Twitter (X) uses its own meta tags. If Twitter tags are not present, it falls back to Open Graph tags. The most common card types are:

summary - small square image with title and description

summary_large_image - large rectangular image above the title (recommended)

<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.png" />

Viewport and Charset

These two tags are required on every HTML page for proper rendering:

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

The viewport tag is critical for mobile responsiveness. Without it, mobile browsers render the page at desktop width and zoom out, making text unreadable.

Robots Meta Tag

The robots tag tells search engines whether to index a page and follow its links:

index, follow (default) - index the page and follow all links

noindex, follow - do not index, but follow links

noindex, nofollow - do not index, do not follow links

Use noindex for pages like admin dashboards, staging environments and thank-you pages that should not appear in search results.

Common Mistakes

  • Duplicate titles and descriptions. Every page needs unique meta content. Duplicate content confuses search engines and reduces visibility.
  • Missing og:image. Shared links without images get significantly fewer clicks on social media.
  • Keyword stuffing. Writing unnatural titles packed with keywords hurts more than it helps. Google penalizes obvious keyword stuffing.
  • Relative image URLs. Social media crawlers cannot resolve relative paths. Always use full absolute URLs for og:image.
  • No canonical tag. Without it, search engines may split ranking signals between URL variants (with/without trailing slash, with/without www).

Testing Your Meta Tags

After adding meta tags, always validate them. Use Facebook Sharing Debugger to test Open Graph tags, Twitter Card Validator for Twitter cards, and Google Search Console for general SEO issues. These tools show exactly what crawlers see when they visit your page.

Generate meta tags instantly

Fill in your page details and get complete HTML meta tags for SEO, Open Graph and Twitter Cards with a live Google preview.

Open Meta Tag Generator