Generate JSON-LD structured data for an article page in Next.js
Use the JsonLdForArticle component to generate JSON-LD structured data for an article page in Next.js, including the headline, description, author information, and more.
Requirements
Section titled “Requirements”Before using the file, make sure your project meets the following requirements:
- Next.js 13.0.0 or higher
- Next.js App Router
url(string, required): The URL of the pageheadline(string, required): The headline of the articledescription(string, required): The description of the articleimage(string, required): The image associated with the articledatePublished(string, required): The publication date of the articledateModified(string, required): The last modification date of the articleauthor(Object, required): The author information of the articleauthor.name(string, required): The name of the author of the articleauthor.url(string, required): The URL of the author of the article
Add the file to your project
Section titled “Add the file to your project”Copy the JsonLdForArticle.tsx or JsonLdForArticle.jsx file to your project.
Import the JsonLdForArticle component
Section titled “Import the JsonLdForArticle component”Import the JsonLdForArticle component into every page where you want to generate the JSON-LD structured data.
import { JsonLdForArticle } from "@/components/JsonLdForArticle";
export default function Page() { return ( <JsonLdForArticle url="https://novajs.dev/getting-started" headline="Getting started with Nova.js" description="Learn how to add dependency-free React hooks to your project in 3 easy steps." image="https://novajs.dev/getting-started.png" datePublished="2024-01-06" dateModified="2025-01-06" author={{ name: "Daniel Castillo", url: "https://dlcastillop.com" }} /> );}