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 requiresreact-helmet-async:
Usage
Basic Usage
With All Props
Props
The component accepts the following props:Page title. Falls back to
meta.defaultTitle from siteContentPage description for meta tags. Falls back to
meta.defaultDescriptionSocial sharing image URL. Falls back to
meta.defaultImageCanonical page URL. Falls back to
meta.siteUrlOpen Graph content type. Common values:
website, article, profileTypeScript Interface
Meta Configuration
The component reads default values fromsiteContent.meta:
Generated Meta Tags
The component generates the following meta tags:Basic Meta Tags
Open Graph Tags
Twitter Card Tags
Title Template
The component usestitleTemplate for formatting:
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 usessummary_large_image for Twitter cards, which displays a large image preview when shared on Twitter.
Best Practices
- Always provide a title and description for better SEO
- Use high-quality images (minimum 1200x630px for OG images)
- Provide unique content for each page
- Use absolute URLs for images and canonical URLs
- Set appropriate Open Graph type (
articlefor blog posts,websitefor pages)
Example Configuration
Component Location
components/SEO.tsx:13