Skip to main content
seofields
docs
.md

Country

The Country schema type identifies a sovereign nation with its name, ISO code, and authoritative same-as references. It is the building block search engines use to understand geographic scope on travel, e-commerce, and reference sites.

About Country

Country is a specialised Place subtype. Adding ISO codes plus sameAs links to Wikidata anchors your entity in Google's Knowledge Graph and prevents ambiguity between similarly named places. Use Country wherever you would otherwise describe a region — for nested locality data prefer the Place or PostalAddress types.

Fields

FieldTypeRequiredDescription
namestring✓The common English name of the country, e.g. "United States".
alternateNamestring—Alternate name (native name or abbreviation).
identifierstring | PropertyValue—ISO 3166-1 alpha-2 country code, e.g. "US", "DE", "JP".
descriptiontext—A short description of the country.
urlurl—Canonical URL — e.g. Wikipedia or official government site.
imageurl | ImageObject—An image representing the country, such as a flag.
sameAsurl—URL to authoritative pages (Wikidata, Wikipedia, GeoNames, etc.).
address.addressCountrystring—ISO country code as a postal address.

Plugin Registration

sanity.config.ts
import { defineConfig } from 'sanity'
import { schemaOrgCountryPlugin } from 'sanity-plugin-seofields/schema'

export default defineConfig({
  // ... your sanity config
  plugins: [
    schemaOrgCountryPlugin(),
  ],
})

Schema Usage

Add the schemaOrgCountry field to any document schema:

schemas/country.ts
import { defineField, defineType } from 'sanity'

export default defineType({
  name: 'country',
  title: 'Country',
  type: 'document',
  fields: [
    defineField({
      name: 'schemaOrgCountry',
      title: 'Country Schema',
      type: 'schemaOrgCountry',
    }),
  ],
})

GROQ Query

GROQ query
*[_type == "country"][0]{
  schemaOrgCountry {
    name,
    alternateName,
    identifier,
    description,
    url,
    image,
    sameAs,
    address
  }
}

Next.js Component

app/layout.tsx
import { CountrySchema } from 'sanity-plugin-seofields/schema/next'

export default function Layout({ data }) {
  return <CountrySchema data={data.schemaOrgCountry} />
}

JSON-LD Output

Generated JSON-LD
{
  "@context": "https://schema.org",
  "@type": "Country",
  "name": "Japan",
  "alternateName": "日本",
  "identifier": "JP",
  "description": "An island nation in East Asia, located in the northwest Pacific Ocean.",
  "url": "https://en.wikipedia.org/wiki/Japan",
  "image": "https://example.com/flags/jp.svg",
  "sameAs": "https://www.wikidata.org/wiki/Q17",
  "address": {
    "@type": "PostalAddress",
    "addressCountry": "JP"
  }
}

Was this page helpful?