docs
Product
Add Product structured data to your Sanity-powered site. Enable rich results with pricing, availability, and ratings in Google Shopping and search.
About Product
Product schema enables rich results with pricing, availability, and ratings in Google Shopping and search. Marking up your products with structured data helps them stand out in search results and can improve click-through rates for e-commerce pages.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | The name of the product. |
imageUrl | string | — | URL of the product image. |
description | string | — | A description of the product. |
brand.name | string | — | The brand or manufacturer name of the product. |
Plugin Registration
sanity.config.ts
import { defineConfig } from "sanity";
import { schemaOrgProductPlugin } from "sanity-plugin-seofields/schema";
export default defineConfig({
// ... your project config
plugins: [
schemaOrgProductPlugin(),
],
});Schema Usage
Add theschemaOrgProduct field to any document schema:
schemas/page.ts
import { defineField, defineType } from 'sanity'
export default defineType({
name: 'page',
title: 'Page',
type: 'document',
fields: [
// ... your other fields
defineField({
name: 'schemaOrgProduct',
title: 'Product Schema',
type: 'schemaOrgProduct',
}),
],
})GROQ Query
GROQ query
const query = groq`*[_type == "product"][0]{
"product": schemaOrgProduct {
name,
"imageUrl": imageUrl,
description,
"brand": brand { name }
}
}`;Next.js Component
app/layout.tsx
import { ProductSchema } from "sanity-plugin-seofields/react";
export default function Layout({ children }: { children: React.ReactNode }) {
// Fetch your product data from Sanity
const product = await sanityClient.fetch(query);
return (
<html lang="en">
<body>
<ProductSchema data={product.product} />
{children}
</body>
</html>
);
}JSON-LD Output
Generated JSON-LD
{
"@context": "https://schema.org",
"@type": "Product",
"name": "sanity-plugin-seofields Pro",
"image": "https://example.com/product.jpg",
"description": "A comprehensive SEO plugin for Sanity CMS with Schema.org support.",
"brand": {
"@type": "Brand",
"name": "Sanity Plugins"
}
}Was this page helpful?