How to Fix Duplicate @id Values in Nested Schema Blocks

By Ryan York

Learn how to resolve duplicate @id errors in your JSON-LD for better structured data and SEO.

Why Do Duplicate @id Values Occur in JSON-LD and How Can You Prevent Them?

Duplicate @id values in nested JSON-LD schema blocks can cause confusion for search engines and lead to structured data errors. This guide explains why these errors occur and how to fix them.

What is the @id Property?

The @id property in JSON-LD is used to uniquely identify nodes within your structured data. It acts as an anchor for referencing entities across different schema blocks.

Why Duplicate @id Errors Happen

Duplicate @id values typically occur when:

  • Copy-pasting schema blocks without updating the @id
  • Generating schema programmatically without unique IDs
  • Using the same @id for different entities (e.g., multiple products, reviews, or organizations)

Example of a Duplicate @id Error

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Product",
      "@id": "#product",
      "name": "Widget A"
    },
    {
      "@type": "Product",
      "@id": "#product",
      "name": "Widget B"
    }
  ]
}

Problem: Both products use @id: #product.

How to Fix Duplicate @id Values

  1. Ensure Each @id is Unique:
    • Use unique values for each entity, e.g., #product-a, #product-b.
  2. Update References:
    • If other schema blocks reference these IDs, update those references as well.

Fixed Example:

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Product",
      "@id": "#product-a",
      "name": "Widget A"
    },
    {
      "@type": "Product",
      "@id": "#product-b",
      "name": "Widget B"
    }
  ]
}

Best Practices

  • Always generate unique @id values for each entity.
  • Use descriptive IDs (e.g., #review-1, #org-main).
  • Validate your schema with Google's Rich Results Test.

Conclusion

Unique @id values are essential for clear, valid structured data. Regularly audit your schema to prevent duplicate IDs and ensure optimal SEO.