Skip to main content
The SEO component manages page metadata, including title, description, Open Graph tags, and Twitter cards using react-helmet-async.

Features

  • Dynamic page title with template support
  • Meta description management
  • Open Graph tags for social sharing
  • Twitter card metadata
  • Favicon configuration
  • Language attribute setting
  • Image and URL metadata

Installation

The component requires react-helmet-async:

Usage

Basic Usage

With All Props

Props

The component accepts the following props:
string
Page title. Falls back to meta.defaultTitle from siteContent
string
Page description for meta tags. Falls back to meta.defaultDescription
string
Social sharing image URL. Falls back to meta.defaultImage
string
Canonical page URL. Falls back to meta.siteUrl
string
default:"website"
Open Graph content type. Common values: website, article, profile

TypeScript Interface

Meta Configuration

The component reads default values from siteContent.meta:

Generated Meta Tags

The component generates the following meta tags:

Basic Meta Tags

Open Graph Tags

Twitter Card Tags

Title Template

The component uses titleTemplate for formatting:
If titleTemplate is "%s | VENCOL" and title is "Blog", the final title will be "Blog | VENCOL".

Implementation Example

Here’s how it’s used in the Home page:

SEO Object Structure

Internally, the component builds a SEO object with fallbacks:

Language Configuration

The component sets the HTML lang attribute to Spanish:
To change the language, modify the lang attribute in the component.

Twitter Card Type

The component uses summary_large_image for Twitter cards, which displays a large image preview when shared on Twitter.

Best Practices

  1. Always provide a title and description for better SEO
  2. Use high-quality images (minimum 1200x630px for OG images)
  3. Provide unique content for each page
  4. Use absolute URLs for images and canonical URLs
  5. Set appropriate Open Graph type (article for blog posts, website for pages)

Example Configuration

Component Location

components/SEO.tsx:13