Start Here · Lesson 3 of 15

Adding Schema to Your Site

You've written a JSON-LD block. Now it needs a home. The good news: every major platform has a place to paste it, and the rules are the same everywhere.

8 min readBeginnerHTML, WordPress, Webflow, Squarespace, Framer, React

The full wrapper

In Lesson 2 we looked at the JSON on its own. On a real page, it always lives inside this script tag. This is the thing you'll paste:

HTML · JSON-LD script tag
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "@id": "https://fernandink.example/#organization",
  "name": "Fern & Ink",
  "url": "https://fernandink.example/",
  "logo": "https://fernandink.example/images/logo.png",
  "telephone": "+1-612-555-0142",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "412 Main St SE",
    "addressLocality": "Minneapolis",
    "addressRegion": "MN",
    "postalCode": "55414",
    "addressCountry": "US"
  }
}
</script>

Two details matter. The type must be exactly application/ld+json. And the tag holds only JSON: no HTML, no comments, nothing else.

Head or body?

Both work. Google reads JSON-LD in the <head> or anywhere in the <body>. The head is the tidy, conventional spot, and it's what most platforms' "custom code" boxes target. If your tool only lets you add code to the body, that's fine too.

One caution: Google can read JSON-LD that JavaScript adds after the page loads, but not every crawler runs JavaScript. When you have the choice, put the markup in the HTML the server sends.

One block or several?

Also both fine. You can have one block with an @graph holding everything, or several separate blocks on the same page. Search engines read all of them.

Our advice: use one @graph per page when you control the whole thing, because it's easier to read and keep consistent. If a plugin outputs one block and you add another, that's OK, as long as they don't contradict each other. Use @id to connect them (Lesson 2) instead of describing the same organization twice.

Platform by platform

Platforms rename their menus every so often, so treat the names below as "look for something like this." The idea doesn't change: find the place that adds code to the page head, site-wide or per page.

Static HTML

Paste the script tag just before </head>. Site-wide markup (your Organization and WebSite) goes on the homepage at minimum; page-specific markup (an article, an event) goes on that page. If you use a template or include for your <head>, put shared markup there once.

WordPress

Check before you add anything. SEO plugins like Yoast SEO and Rank Math already output a full schema graph, usually Organization (or Person), WebSite, WebPage, and BreadcrumbList, all connected with @id. View your page source and search for ld+json. Yoast's block usually has the class yoast-schema-graph; Rank Math's usually says rank-math-schema.

  • If a plugin is already outputting schema, fill in its settings first (organization name, logo, social profiles). That fixes most of the basics without writing any code.
  • For extra markup the plugin doesn't cover, use a header-snippet plugin (look for one that adds code to the head, site-wide or per page) or your theme's own "header scripts" box. Developers can hook into wp_head in a child theme.
  • Don't paste a second Organization block on top of the plugin's. Either configure the plugin, or turn its schema off and write your own.

Using Yoast? The Yoast SEO platform guide walks through every schema setting and shows exactly which types Yoast covers.

Webflow

For site-wide markup, look in Site settings → Custom code for the head code box. For one page, open that page's settings and find the custom code area for "Inside <head> tag." Custom code may require a paid site plan to publish.

The handy part: on CMS template pages (a blog post template, say), the page-level custom code box lets you insert CMS fields into your JSON. So the headline can pull the post's Name field and the datePublished can pull its date. Look for an "add field" option in the code box. Test a published page afterward, because a field with a stray quote mark in it can break the JSON.

Squarespace

Use Code Injection. Site-wide, look under your site's settings (often in an Advanced or Developer Tools section) for the Header box. For a single page, open the page's settings and look for its own header code injection. Code injection is only available on some plans, so check yours.

Framer

Look in Site Settings for a Custom Code section, which lets you add code to the start or end of the <head> on every page. Individual pages also have their own custom code setting in their page settings. Paste the full script tag, then publish.

React and Next.js

Render a <script> element and pass your data through JSON.stringify with dangerouslySetInnerHTML. That's the scary-sounding React prop for "put this exact text inside the tag." In the Next.js App Router, put it right in your page component (a page.tsx or page.js file), so it's rendered on the server with the rest of the page.

JSX · Next.js App Router page
export default function AboutPage() {
  const jsonLd = {
    "@context": "https://schema.org",
    "@type": "Organization",
    "@id": "https://fernandink.example/#organization",
    name: "Fern & Ink",
    url: "https://fernandink.example/",
  };

  return (
    <main>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
        }}
      />
      <h1>About Fern & Ink</h1>
    </main>
  );
}

Writing the data as a JavaScript object means JSON.stringify handles the quotes and commas for you, so you can't make the syntax mistakes from Lesson 2. The .replace escapes any < characters so content pulled from a CMS can't break out of the script tag. For data from a CMS or API, build the object from that data instead of typing it in.

Common mistakes: duplicates and contradictions

The most common schema problem we see isn't a typo. It's two tools describing the same thing differently. A theme outputs an Organization called "Fern and Ink Studio," an SEO plugin outputs one called "Fern & Ink," and then someone pastes a third by hand. Now machines have three answers to one question.

Look before you pasteBefore adding any schema, view the page source and search for ld+json. Count the blocks, and note who's making each one: the theme, an SEO plugin, a reviews widget, an events plugin. Pick one source for each thing (one Organization, one WebSite) and turn off or configure the rest.

  • Pasting site-wide markup into every page by hand. Use the platform's site-wide box once instead. Hand copies drift out of sync.
  • Leaving old markup behind. When you switch SEO plugins or themes, check that the old one's schema is actually gone.
  • Pasting the JSON without the script tag. The JSON shows up as visible text on your page. If you see curly braces in your footer, that's why.

Try it

Pick a site you work on and view the source of its homepage (right-click, then View Page Source). Search for ld+json. How many blocks are there? What's generating each one? Is the organization's name spelled the same in all of them? Jot down what you find. You'll fix it in the Foundations unit.

Check yourself

  • I know JSON-LD works in the head or the body, and the head is the usual spot.
  • I know one block or several both work, and I connect them with @id.
  • I can find where my platform lets me add code to the page head.
  • I check for plugin or theme schema before adding my own.
  • I always include the full <script type="application/ld+json"> wrapper.
Go deeper on Double Atari

Why this work is worth doing in the first place: Schema Markup, Explained for Marketers.