docs
Course Schema
Add Course structured data to your Sanity documents to enable educational content to appear in Google's course rich results.
About Course Schema
Course schema enables educational content to appear in Google's course rich results. When properly implemented, Google can display course details such as the provider, description, and ratings directly in search results, helping learners discover your educational offerings more easily.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Required | The title of the course. |
| description | string | Optional | A description of the course content and objectives. |
| provider.name | string | Optional | The name of the organization or institution offering the course. |
| provider.sameAs | string | Optional | A URL identifying the course provider (e.g. their website). |
Plugin Registration
sanity.config.ts
import { defineConfig } from "sanity";
import { seoFields } from "sanity-plugin-seofields";
import { schemaOrgCoursePlugin } from "sanity-plugin-seofields/schema";
export default defineConfig({
// ...your sanity config
plugins: [
seoFields(),
schemaOrgCoursePlugin(),
],
});Schema Usage
Add theschemaOrgCourse 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: 'schemaOrgCourse',
title: 'Course Schema',
type: 'schemaOrgCourse',
}),
],
})GROQ Query
GROQ
*[_type == "yourDocumentType"][0]{
...,
schemaOrgCourse
}Next.js Component
app/page.tsx
import { CourseSchema } from "sanity-plugin-seofields/schema-org/next";
export default function Page({ data }) {
return (
<>
<CourseSchema data={data.schemaOrgCourse} />
{/* Your page content */}
</>
);
}JSON-LD Output
JSON-LD
{
"@context": "https://schema.org",
"@type": "Course",
"name": "Introduction to Web Development",
"description": "...",
"provider": {
"@type": "Organization",
"name": "Code Academy",
"sameAs": "https://codeacademy.com"
}
}Was this page helpful?