Skip to main content
seofields
docs

Offer

Add Offer structured data to your Sanity-powered site. Provide pricing information for products and services so Google can display it directly in search results.

About Offer

Offer schema provides pricing information for products and services, used by Google for price comparisons and shopping results. Including offer data alongside your Product markup gives search engines the full picture of what you sell and at what price.

Fields

FieldTypeRequiredDescription
pricenumberThe price of the product or service.
priceCurrencystringThe currency of the price (e.g. USD, EUR, GBP).
availabilitystringThe availability status URL (e.g. https://schema.org/InStock).
urlstringA URL where the offer can be acquired.

Plugin Registration

sanity.config.ts
import { defineConfig } from "sanity";
import { schemaOrgOfferPlugin } from "sanity-plugin-seofields/schema";

export default defineConfig({
  // ... your project config
  plugins: [
    schemaOrgOfferPlugin(),
  ],
});

Schema Usage

Add theschemaOrgOffer 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: 'schemaOrgOffer',
      title: 'Offer Schema',
      type: 'schemaOrgOffer',
    }),
  ],
})

GROQ Query

GROQ query
const query = groq`*[_type == "product"][0]{
  "offer": schemaOrgOffer {
    price,
    priceCurrency,
    availability,
    url
  }
}`;

Next.js Component

app/layout.tsx
import { OfferSchema } from "sanity-plugin-seofields/react";

export default function Layout({ children }: { children: React.ReactNode }) {
  // Fetch your offer data from Sanity
  const product = await sanityClient.fetch(query);

  return (
    <html lang="en">
      <body>
        <OfferSchema data={product.offer} />
        {children}
      </body>
    </html>
  );
}

JSON-LD Output

Generated JSON-LD
{
  "@context": "https://schema.org",
  "@type": "Offer",
  "price": 29.99,
  "priceCurrency": "USD",
  "availability": "https://schema.org/InStock",
  "url": "https://example.com/products/seo-plugin"
}

Was this page helpful?