docs
PostalAddress
Add PostalAddress structured data to your Sanity-powered site. Provide structured location data for organizations and local businesses.
About PostalAddress
PostalAddress provides structured location data, typically nested inside Organization or LocalBusiness. Using structured address data helps search engines accurately understand and display your physical location in search results, maps, and knowledge panels.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
streetAddress | string | — | The street address (e.g. 123 Main St). |
addressLocality | string | — | The city or locality. |
postalCode | string | — | The postal or ZIP code. |
addressCountry | string | — | The country (ISO 3166-1 alpha-2 code). |
Plugin Registration
sanity.config.ts
import { defineConfig } from "sanity";
import { schemaOrgPostalAddressPlugin } from "sanity-plugin-seofields/schema";
export default defineConfig({
// ... your project config
plugins: [
schemaOrgPostalAddressPlugin(),
],
});Schema Usage
Add theschemaOrgPostalAddress 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: 'schemaOrgPostalAddress',
title: 'Postal Address',
type: 'schemaOrgPostalAddress',
}),
],
})GROQ Query
GROQ query
const query = groq`*[_type == "postalAddress"][0]{
"postalAddress": schemaOrgPostalAddress {
streetAddress,
addressLocality,
postalCode,
addressCountry
}
}`;Next.js Component
app/layout.tsx
import { PostalAddressSchema } from "sanity-plugin-seofields/react";
export default function Layout({ children }: { children: React.ReactNode }) {
// Fetch your postal address data from Sanity
const postalAddress = await sanityClient.fetch(query);
return (
<html lang="en">
<body>
<PostalAddressSchema data={postalAddress.postalAddress} />
{children}
</body>
</html>
);
}JSON-LD Output
Generated JSON-LD
{
"@context": "https://schema.org",
"@type": "PostalAddress",
"streetAddress": "123 Main St",
"addressLocality": "Springfield",
"postalCode": "62701",
"addressCountry": "US"
}Was this page helpful?