SEO & Metadata Builder
Prerequisites & Dependencies
- Node.js 18+ or a build tool (Vite, Webpack, Next.js)
- Mandatory packages:
npm i next-seo (for Next.js) or manual template generation
- Access to the application's data: page title, description, site URL, author, and entity types
- Optional:
npm i react-helmet for dynamic meta management in React
Execution Steps
- Inventory all pages that need SEO metadata: home, articles, product pages, error pages
- For each page, collect the required fields:
title, description, url, image, type, siteName, and social handles
- Generate HTML meta tags:
<title>, <meta name="description">, <meta charset>, <meta viewport>
- Add Open Graph tags:
og:title, og:description, og:image, og:url, og:type, og:locale
- Add Twitter Card tags:
twitter:card, twitter:title, twitter:description, twitter:image, twitter:creator
- Generate JSON-LD structured data:
@context, @type (e.g., Article, Product, Organization), and relevant properties (author, datePublished, price, availability)
- Insert all tags into your
_document.js (Next.js) or head component, ensuring they are server-rendered and hydrated correctly
- Validate your markup: use
Google Search Console, Facebook Sharing Debugger, and schema.org validators
// Example: Comprehensive SEO component for Next.js using next-seo
import React from 'react';
import { NextSeo } from 'next-seo';
const SeoMetadata = ({ title, description, image, slug }) => (
<NextSeo
title={title}
description={description}
openGraph={{
type: 'website',
url: `https://example.com${slug}`,
images: [{ url: image, width: 1200, height: 630 }],
}}
twitter={{
card: 'summary_large_image',
title,
description,
images: [image],
}}
jsonLD={[
{
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'Example Corp',
url: 'https://example.com',
logo: '/logo.png',
},
]}
/>
);
export default SeoMetadata;
1---2name: seo-metadata-builder3description: Generate complete HTML meta tags, Open Graph, Twitter Cards, and JSON-LD structured data.4---56# SEO & Metadata Builder78## Prerequisites & Dependencies9- Node.js 18+ or a build tool (Vite, Webpack, Next.js)10- Mandatory packages: `npm i next-seo` (for Next.js) or manual template generation11- Access to the application's data: page title, description, site URL, author, and entity types12- Optional: `npm i react-helmet` for dynamic meta management in React1314## Execution Steps151. Inventory all pages that need SEO metadata: home, articles, product pages, error pages162. For each page, collect the required fields: `title`, `description`, `url`, `image`, `type`, `siteName`, and social handles173. Generate HTML meta tags: `<title>`, `<meta name="description">`, `<meta charset>`, `<meta viewport>`184. Add Open Graph tags: `og:title`, `og:description`, `og:image`, `og:url`, `og:type`, `og:locale`195. Add Twitter Card tags: `twitter:card`, `twitter:title`, `twitter:description`, `twitter:image`, `twitter:creator`206. Generate JSON-LD structured data: `@context`, `@type` (e.g., `Article`, `Product`, `Organization`), and relevant properties (`author`, `datePublished`, `price`, `availability`)217. Insert all tags into your `_document.js` (Next.js) or `head` component, ensuring they are server-rendered and hydrated correctly228. Validate your markup: use `Google Search Console`, `Facebook Sharing Debugger`, and `schema.org validators`2324```javascript25// Example: Comprehensive SEO component for Next.js using next-seo26import React from 'react';27import { NextSeo } from 'next-seo';2829const SeoMetadata = ({ title, description, image, slug }) => (30 <NextSeo31 title={title}32 description={description}33 openGraph={{34 type: 'website',35 url: `https://example.com${slug}`,36 images: [{ url: image, width: 1200, height: 630 }],37 }}38 twitter={{39 card: 'summary_large_image',40 title,41 description,42 images: [image],43 }}44 jsonLD={[45 {46 '@context': 'https://schema.org',47 '@type': 'Organization',48 name: 'Example Corp',49 url: 'https://example.com',50 logo: '/logo.png',51 },52 ]}53 />54);5556export default SeoMetadata;57```