Skip to main content
seofields
docs

LocalBusiness

Add LocalBusiness structured data to your Sanity-powered site. Appear in Google's local pack results and Maps listings with rich business information.

About LocalBusiness

LocalBusiness schema powers Google's local pack results and Maps listings. Structured business data helps your business appear prominently when users search for local services, complete with address, phone number, and business details.

Fields

FieldTypeRequiredDescription
namestringThe name of the local business.
imagestringURL of the business image or photo.
telephonestringThe phone number of the business.
address.streetAddressstringThe street address of the business.
address.addressLocalitystringThe city or locality of the business.
address.addressCountrystringThe country of the business (ISO 3166-1 alpha-2).

Plugin Registration

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

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

Schema Usage

Add theschemaOrgLocalBusiness 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: 'schemaOrgLocalBusiness',
      title: 'Local Business Schema',
      type: 'schemaOrgLocalBusiness',
    }),
  ],
})

GROQ Query

GROQ query
const query = groq`*[_type == "localBusiness"][0]{
  "localBusiness": schemaOrgLocalBusiness {
    name,
    image,
    telephone,
    "address": address {
      streetAddress,
      addressLocality,
      addressCountry
    }
  }
}`;

Next.js Component

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

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

  return (
    <html lang="en">
      <body>
        <LocalBusinessSchema data={localBusiness.localBusiness} />
        {children}
      </body>
    </html>
  );
}

JSON-LD Output

Generated JSON-LD
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "Springfield Coffee House",
  "image": "https://example.com/coffee-house.jpg",
  "telephone": "+1-555-0100",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "123 Main St",
    "addressLocality": "Springfield",
    "addressCountry": "US"
  }
}

Was this page helpful?