Structured Data

How to Add JSON-LD to Your Website

Add JSON-LD schema markup in five steps: pick the type, generate the code, place it in the page, test it and keep it accurate. Includes examples.

By Franel II Romanillos, Technical SEO Specialist

#json-ld #schema markup #structured data

To add JSON-LD to a website, generate the markup for the right schema.org type, paste it into a <script type="application/ld+json"> tag in the page’s HTML, and test it. Google reads JSON-LD in the head or the body, so either location works.

If you are new to the topic, read What Is Schema Markup? first.

Step 1: Choose the right type for the page

Match the type to what the page is about, not to what you hope to rank for:

  • Blog post or guide: Article
  • Product page: Product
  • A business with a location: LocalBusiness
  • Homepage or About page: Organization
  • Author or team member page: Person
  • Service page: Service
  • Event page: Event

Add supporting types, such as an Organization that publishes an Article, when they help. Do not mark up anything the page does not show.

Step 2: Generate the JSON-LD

You can write it by hand, but a generator avoids typos and structural mistakes. The Schema Markup Generator lets you analyze a page, fill in the fields, remove optional properties you cannot answer accurately, and copy the result as one combined script or separate scripts.

A combined script uses @graph, so pieces can refer to each other with @id:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://example.com/#organization",
      "name": "Example Co",
      "url": "https://example.com/"
    },
    {
      "@type": "Article",
      "headline": "How to Check Image Alt Text",
      "datePublished": "2026-10-01",
      "author": { "@type": "Person", "name": "Jane Doe" },
      "publisher": { "@id": "https://example.com/#organization" }
    }
  ]
}
</script>

Google advises supplying fewer properties that are complete and accurate over filling in every property with weak data, so leave out anything you cannot state truthfully.

Step 3: Put it in the page

Paste the script into the HTML of the page it describes. Where depends on how your site is built.

Plain HTML

Add it inside the head (or body) of the page, once per page or per group of related items.

WordPress and other CMS platforms

Many SEO plugins output JSON-LD automatically, so first check what your site already produces before adding more. If you add your own, use the plugin’s custom schema option or your theme’s header code area for that page. Avoid duplicates, such as two Organization entries with different names or logos.

Astro and other static site frameworks

In an Astro component, serialize an object and insert it with set:html:

---
const schema = {
  "@context": "https://schema.org",
  "@type": "Article",
  headline: "How to Add JSON-LD to Your Website",
  datePublished: "2026-11-03",
};
const json = JSON.stringify(schema).replace(/</g, "\\u003c");
---
<script type="application/ld+json" set:html={json} />

The replace step keeps any < in your data from ending the script tag early, which matters if text from outside sources ever ends up in the markup.

Step 4: Test it

  1. Run the page through Google’s Rich Results Test to see whether it is eligible for supported rich results.
  2. Use the Schema Markup Validator to check the vocabulary and structure, whether or not Google uses the type.
  3. After the page is live, use the URL Inspection tool in Search Console to confirm Google has found the structured data.
  4. View the page source or inspect the page to check that the script appears once and shows the values you expect.

Google says it can read JSON-LD that JavaScript adds to the page, but it is simpler to check and more dependable to include it in the HTML the server sends.

Step 5: Keep it accurate

Structured data goes stale quietly. Update it when the page changes, especially prices, availability, dates, addresses and opening hours. To see which pages on your site have markup and which do not, crawl it with the Page Audit Checker, which lists the schema types found on each page.

Common mistakes

  • Marking up content that is not visible on the page.
  • Pasting the same Organization or LocalBusiness block onto every page with edits that do not match the page.
  • Leaving a plugin’s default markup running alongside your own and creating conflicting entries.
  • Using placeholder values such as example phone numbers or fake reviews.
  • Forgetting to update prices, dates or hours after the page changes.
  • Adding markup types that no longer produce a rich result and never reviewing whether it is still worth maintaining. See FAQ Schema in 2026 for an example.

For a review of structured data across your whole site, see our structured data service.

Frequently asked questions

Should JSON-LD go in the head or the body?

Either. Google reads JSON-LD in both. Many sites put it in the head for tidiness.

Can I use more than one JSON-LD script on a page?

Yes. You can use several scripts or one script with an @graph. Keep the details consistent between them.

Do I need to add JSON-LD to every page?

No. Add it where it accurately describes the page and has a purpose, such as the homepage, services, products, articles and events.

Why does the Rich Results Test not show my markup?

The tool only reports the types Google supports for rich results. Use the Schema Markup Validator to check other types, and check that the script is actually present in the page the tool is fetching.

Do I need a developer to add JSON-LD?

Not always. A CMS or SEO plugin can often add custom markup. For a static or custom site, you or a developer paste it into the page template.

Sources

  1. Google Search Central: Introduction to structured data markup in Google Search
  2. Schema.org
  3. W3C: JSON-LD 1.1 Specification
  4. Astro Docs: Template directives reference (set:html)