Skip to content
Back to skills

Structured Data

ASecurity

Use when the user asks to add JSON-LD structured data, schema.org markup, rich results, Product, Article, BreadcrumbList or Organization schema, review stars, or Rich Results Test errors. Produces valid, XSS-safe JSON-LD rendered server-side and validated in CI. Not for meta tags and Open Graph (use frontend-seo) or crawl issues (use seo-fundamentals).

  • 46 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 27, 2026
ai-agentsgoreactnextjsnodefrontend

Works with

  • cli

Security analysis

A100/100

Scanned November 27, 2026

npx -y skills add j4flmao/agent-skills --skill structured-data --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Structured Data?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Structured Data
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/j4flmao-structured-data/badge)](https://www.skillsdirectory.com/skills/j4flmao-structured-data)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: seo-structured-data
description: >
  Use when the user asks to add JSON-LD structured data, schema.org markup, rich results, Product, Article, BreadcrumbList or Organization schema, review stars, or Rich Results Test errors. Produces valid, XSS-safe JSON-LD rendered server-side and validated in CI. Not for meta tags and Open Graph (use frontend-seo) or crawl issues (use seo-fundamentals).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
last_verified: "2026-11-17"
tags: [seo, structured-data, json-ld, schema-org, rich-results]
---

# Structured Data (JSON-LD)

## Purpose
Structured data describes page content with the schema.org vocabulary so search engines can understand entities and show rich results (product price/availability, review stars, breadcrumbs, article info, events, recipes, videos). Google recommends JSON-LD. Markup only makes a page **eligible**; Google decides whether to show a rich result, and markup must describe content visible on the page.

## Agent Protocol

### Trigger
"json-ld", "schema.org", "structured data", "rich results", "rich snippets", "Product markup", "BreadcrumbList", "Organization logo", "Merchant listing".

### Input Context
- Page types (product, article, category, local business, event, video, recipe).
- Data available per page (price, currency, availability, ratings, author, dates).
- Rendering (SSR/SSG vs. client-only SPA) and framework.

### Output Artifact
Typed JSON-LD builders per page type, rendering component, validation step.

### Response Format
```
Page type: {type}
Schema: {@type list}
Required props: {Google-required fields present?}
Recommended props: {added}
Rendering: {server HTML|client}
Validation: {Rich Results Test / Schema Markup Validator / CI}
```

## Which Types Still Produce Rich Results
| Type | Notes |
|------|-------|
| `Product` + `Offer` / `AggregateRating` / `Review` | Product snippets and merchant listings; self-serving reviews of your own business (LocalBusiness/Organization) are not eligible for stars |
| `Article` / `NewsArticle` / `BlogPosting` | Helps title, image, date understanding |
| `BreadcrumbList` | Breadcrumb trail (shown on desktop results) |
| `Organization` | Logo, name, contact info in knowledge panels |
| `LocalBusiness` | Business details; Google Business Profile matters more |
| `Event`, `Recipe`, `VideoObject`, `JobPosting`, `Course`, `SoftwareApplication` | Type-specific features |
| `FAQPage` | Since Aug 2023 shown only for well-known authoritative government/health sites |
| `HowTo` | Rich result deprecated (2023); markup harmless but no display |

Check Google Search Central's current "Search gallery" before promising a rich result; the list changes.

## Typed Builders

```ts
// lib/schema.ts
import type { Product as SchemaProduct, WithContext, BreadcrumbList } from 'schema-dts';

export interface ProductData {
  name: string; description: string; sku: string; url: string; images: string[];
  brand: string; price: number; currency: string; inStock: boolean;
  rating?: { value: number; count: number };
}

export function productJsonLd(p: ProductData): WithContext<SchemaProduct> {
  return {
    '@context': 'https://schema.org',
    '@type': 'Product',
    name: p.name,
    description: p.description,
    sku: p.sku,
    image: p.images,
    brand: { '@type': 'Brand', name: p.brand },
    offers: {
      '@type': 'Offer',
      url: p.url,
      price: p.price.toFixed(2),
      priceCurrency: p.currency,
      availability: p.inStock ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
      itemCondition: 'https://schema.org/NewCondition',
    },
    ...(p.rating && p.rating.count > 0
      ? { aggregateRating: { '@type': 'AggregateRating', ratingValue: p.rating.value, reviewCount: p.rating.count } }
      : {}),
  };
}

export function breadcrumbJsonLd(items: { name: string; url: string }[]): WithContext<BreadcrumbList> {
  return {
    '@context': 'https://schema.org',
    '@type': 'BreadcrumbList',
    itemListElement: items.map((item, i) => ({
      '@type': 'ListItem', position: i + 1, name: item.name, item: item.url,
    })),
  };
}
```
`schema-dts` (Google-maintained types) catches misspelled properties at compile time.

## Rendering Safely (React / Next.js)

```tsx
// components/JsonLd.tsx — works in Server Components
export function JsonLd({ data }: { data: object }) {
  return (
    <script
      type="application/ld+json"
      // Escape "<" so data containing "</script>" cannot break out of the tag (XSS)
      dangerouslySetInnerHTML={{ __html: JSON.stringify(data).replace(/</g, '\\u003c') }}
    />
  );
}
```
```tsx
// app/products/[slug]/page.tsx
export default async function ProductPage({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const product = await getProduct(slug);
  return (
    <>
      <JsonLd data={productJsonLd(product)} />
      <JsonLd data={breadcrumbJsonLd([{ name: 'Home', url: 'https://example.com/' }, { name: product.name, url: product.url }])} />
      <ProductView product={product} />
    </>
  );
}
```
- JSON-LD may live in `<head>` or `<body>`; server-render it so every crawler sees it (Google can read JS-injected JSON-LD, many others cannot).
- `react-helmet` is unmaintained; in non-Next React apps use `react-helmet-async` or render the script directly.

## Linking Entities with @id
Use stable `@id` URLs to connect entities across pages (e.g. `https://example.com/#organization` referenced as `publisher` from every Article). One `@graph` array per page is a clean way to emit several connected nodes.

## Validation
- **Rich Results Test** (Google): eligibility for Google features.
- **Schema Markup Validator** (validator.schema.org): generic schema.org validity.
- **Search Console** enhancement reports: errors/warnings at scale after deploy.
- CI: render key templates, extract `application/ld+json` blocks, `JSON.parse` them and assert required fields with a schema (e.g. zod) so regressions fail the build.

## Rules
- Markup must match visible content (price, rating, availability). Mismatch can trigger a manual action.
- Do not mark up content hidden from users or reviews you wrote about yourself.
- Keep prices/availability in sync with the page (same data source).
- Dates in ISO 8601 with timezone (`2026-10-22T09:00:00+02:00`).
- Absolute URLs for `url`, `image`, `item`.

## Anti-patterns
| Anti-pattern | Fix |
|--------------|-----|
| FAQPage on every page for "more SERP space" | Not displayed for most sites since 2023; skip |
| AggregateRating with zero reviews | Omit the property |
| Client-only injection after hydration | Server-render the script |
| Unescaped `JSON.stringify` in `dangerouslySetInnerHTML` | Escape `<` |
| Hand-written JSON strings | Typed builders |

## Checklist
- [ ] Types chosen from current Google search gallery.
- [ ] Required + recommended properties populated from the same data as the UI.
- [ ] JSON-LD server-rendered and escaped.
- [ ] Rich Results Test passes for each template; CI guards regressions.
- [ ] Search Console enhancement reports monitored.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.