Skip to content

Add JSON-LD structured data to a page

seo-in-nextjs provides the JsonLdScript component to easily add any JSON-LD structured data to a page.

  1. Import the JsonLdScript component into every page where you want to generate the JSON-LD data.

    app/article/getting-started/page.tsx
    import { JsonLdScript } from "@dlcastillop/seo-in-nextjs";
    export default function ArticlePage() {
    const jsonLd = {
    "@context": "https://schema.org",
    "@type": "Article",
    headline: "Getting Started with Next.js",
    author: {
    "@type": "Person",
    name: "John Doe",
    },
    datePublished: "2024-01-15",
    };
    return (
    <>
    <JsonLdScript jsonLd={jsonLd} scriptKey="jsonld-article" />
    <article>
    <h1>Getting Started with Next.js</h1>
    {/* Your content */}
    </article>
    </>
    );
    }
  2. Check the generated JSON-LD by inspecting the body element of your page.

View related API references.