# Schema.org markup passes basic validity checks

- **Pattern:** `ab-001673` (`marketing-advanced-seo.structured-data.schema-validity`)
- **Severity:** high
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001673
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001673)

## Why it matters

A JSON syntax error in any `<script type="application/ld+json">` block silently discards the entire schema — Google logs a parse failure and ignores the block, removing that page from Rich Results eligibility. Beyond syntax, schema-org Article and schema-org WebSite define required properties that must be present for Google to trust and surface the markup: an `Article` missing `datePublished` will not appear in Top Stories carousels regardless of content quality. Invalid structured data is equivalent to no structured data from Google's perspective, making this a direct ranking signal failure.

## Severity rationale

High because any syntactically invalid JSON-LD block or missing required property silently disqualifies that page from Rich Results, wasting implementation effort and suppressing SERP visibility.

## Remediation

Lint all JSON-LD before embedding. The fastest fix is running each block through `JSON.parse()` in a build-time script or using the Google Rich Results Test against your staging URL. For `BlogPosting`, the required fields are `headline`, `author` (with `@type: "Person"` and `name`), `datePublished`, and `image`. For `WebSite`, the minimum is `name` and `url`.

Add a validation step in `src/lib/schema.ts` that asserts required fields at build time:

```ts
// src/lib/schema.ts
export function buildArticleSchema(post: Post) {
  if (!post.title || !post.publishedAt || !post.authorName) {
    throw new Error(`Article schema: missing required fields for "${post.slug}"`);
  }
  return {
    '@context': 'https://schema.org',
    '@type': 'BlogPosting',
    headline: post.title,
    datePublished: post.publishedAt,
    author: { '@type': 'Person', name: post.authorName },
  };
}
```

This catches missing properties at build time rather than silently shipping invalid schema to production.

## Detection

- **ID:** `schema-validity`
- **Severity:** `high`
- **What to look for:** Count all JSON-LD blocks and enumerate which pass JSON parsing and which have syntax errors or missing required properties. Examine all `<script type="application/ld+json">` blocks found in the project. Parse each as JSON and check: (1) JSON is syntactically valid (parseable without errors), (2) each block has a `@context` field set to `"https://schema.org"` or `"http://schema.org"`, (3) each block has a `@type` field, (4) required properties for the given `@type` are present. For common types: `WebSite` requires `name`; `Article`/`BlogPosting` requires `headline`, `author`, `datePublished`; `BreadcrumbList` requires `itemListElement`; `Organization` requires `name`.
- **Pass criteria:** All JSON-LD blocks are valid JSON, have `@context` and `@type`, and include the required properties for their type. At least 90% of JSON-LD blocks must be syntactically valid with required properties present.
- **Fail criteria:** Any JSON-LD block has a JSON syntax error, missing `@context` or `@type`, or is missing a required property for its declared type.
- **Skip (N/A) when:** No JSON-LD blocks found in the project (caught by `jsonld-present` check).

- **Cross-reference:** For structured data content matching, see `markup-content-match`.
- **Detail on fail:** Identify the specific file, the @type, and the validation failure. Example: `"Article schema in app/blog/[slug]/page.tsx is missing required 'datePublished' field. Organization schema has JSON syntax error near character 247."`
- **Remediation:** Invalid structured data does not produce rich results and may be ignored by search engines entirely. Fix syntax errors by linting your JSON-LD objects before embedding them. For `BlogPosting`, required fields are: `headline`, `author` (with `@type: Person` and `name`), `datePublished`, `dateModified`, and `description`. Consult schema.org for required properties of other types.

  ```json
  // Validate with Google Rich Results Test — fix missing properties in app/page.tsx JSON-LD blocks
  { "@context": "https://schema.org", "@type": "Organization", "name": "Required", "url": "Required" }
  ```

## External references

- schema-org Article
- schema-org WebSite

Taxons: findability

HTML version: https://auditbuffet.com/patterns/ab-001673
