squirrelscan
GitHub

Fixing structured data identity

Every schema/entity-* finding, what causes it, and the exact change to make in Yoast, Rank Math, WordLift, Next.js, Astro and tangly.

The one idea

Almost every finding in this category comes back to the same thing: your site declares entities and does not say which declarations are the same entity.

Structured data is a graph. A graph needs identifiers. An @id is that identifier. It is an arbitrary string that happens to look like a URL, it does not have to resolve to anything, and it only has to be absolute and identical everywhere.

{
  "@type": "Organization",
  "@id": "https://example.com/#organization",
  "name": "Example Ltd"
}

With that in place, every other page can refer to the organization instead of redeclaring it:

{ "@type": "Article", "publisher": { "@id": "https://example.com/#organization" } }

Two rules of thumb carry most of the value:

  1. Declare once per page, reference everywhere else. The full block can appear in each page’s @graph, which is what Yoast does. What must not happen is the same entity appearing twice with no identifier.
  2. Absolute @id, always. A bare #organization resolves against the page it sits on, so forty pages means forty identifiers.

The shape that works

One script, one @graph, everything referenced by @id:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebPage",
      "@id": "https://example.com/about#webpage",
      "url": "https://example.com/about",
      "name": "About",
      "isPartOf": { "@id": "https://example.com/#website" },
      "about": { "@id": "https://example.com/#organization" }
    },
    {
      "@type": "WebSite",
      "@id": "https://example.com/#website",
      "url": "https://example.com/",
      "name": "Example",
      "publisher": { "@id": "https://example.com/#organization" }
    },
    {
      "@type": "Organization",
      "@id": "https://example.com/#organization",
      "name": "Example Ltd",
      "url": "https://example.com/",
      "logo": "https://example.com/logo.png",
      "sameAs": [
        "https://www.linkedin.com/company/example",
        "https://x.com/example"
      ]
    }
  ]
}
</script>

Three nodes, three identifiers, three references. Repeat this on every page, changing only the WebPage node. The organization is declared in exactly one place per page, so there is no second copy on the page to disagree with the first.

Finding by finding

FindingWhat it meansThe change
entity-identityThe same organization, person or website on many pages with no @idAdd one absolute @id, identical on every page
entity-split-identityOne entity under two different @ids, usually two pluginsPick one, make the other a sameAs or remove it
entity-conflictsThe same entity with two logos, names or phone numbersConverge on one value, then reference instead of repeating
entity-danglingA reference to an @id nothing declaresDeclare the target in the @graph of every page that references it
entity-id-formatAn @id that is not an absolute URLWrite the scheme and host out in full
entity-type-driftOne @id with different @type sets on different pagesEmit the same type array everywhere
entity-authorsA byline with no Person, or a Person with no identifiersDeclare the author with @id, url and sameAs
entity-publisher-mismatchPages that name different publishersOne publisher, referenced by @id
entity-website-missingNo WebSite node, or no isPartOf links to itDeclare it once, reference it from every page
entity-organization-missingA business with no organization entityDeclare it once with sameAs
entity-sameas-missingAn organization with no sameAs profilesList every profile you control
entity-local-business-per-pageThe whole business block on every pageDeclare once, reference elsewhere
entity-orphanAn @id nothing points at, on one pageReference it, or drop the @id

By generator

Yoast SEO

Yoast emits the right shape by default: one @graph per page, stable absolute @ids, everything referenced. When a Yoast site reports an identity finding, look for something else on the page declaring the same entity.

  • Split identity usually means a second source of markup. Turn schema output off in one of them rather than trying to reconcile both.
  • Organization details live under Yoast SEO, Settings, Site representation. Set the organization name, logo and social profiles there; the social profiles become sameAs.
  • A hand-written block added to the theme header years ago will fight Yoast. Search the theme for application/ld+json before blaming the plugin.

Rank Math

Same shape, same advice. Schema and Local SEO settings both live under Rank Math, Titles and Meta.

If you see entity-local-business-per-page, check where the Local SEO markup is being output: the finding means the full business block is reaching nearly every page rather than the home, about and contact pages it is meant for.

WordLift

WordLift identifies entities under data.wordlift.io URLs, which is a legitimate identifier scheme. Running it alongside Yoast produces exactly the two-organization split this category reports.

WordLift documents a configuration that coexists with Yoast; use it rather than running both with their defaults.

If you have a split today, one of the two declarations has to go. Adding the other id as a sameAs is good practice and does NOT resolve the finding on its own, because both organizations are still declared: sameAs records a relationship, it does not remove the second entity.

Next.js

Render one script per page with the complete @graph. Build the @ids from an environment variable so they cannot drift between environments:

const SITE = process.env.NEXT_PUBLIC_SITE_URL!;
const ORG = `${SITE}/#organization`;

/**
 * `<` is escaped because JSON.stringify does not escape it, and a page title
 * containing `</script>` would otherwise close the tag and turn the rest of
 * the JSON into markup. Any value that reaches a JSON-LD block from a CMS
 * needs this.
 */
const embed = (value: unknown): string =>
  JSON.stringify(value).replace(/</g, "\\u003c");

export function Schema({ page }: { page: { url: string; title: string } }) {
  return (
    <script
      type="application/ld+json"
      dangerouslySetInnerHTML={{
        __html: embed({
          "@context": "https://schema.org",
          "@graph": [
            { "@type": "WebPage", "@id": `${page.url}#webpage`, name: page.title,
              isPartOf: { "@id": `${SITE}/#website` } },
            { "@type": "WebSite", "@id": `${SITE}/#website`, url: SITE,
              publisher: { "@id": ORG } },
            { "@type": "Organization", "@id": ORG, name: "Example Ltd", url: SITE },
          ],
        }),
      }}
    />
  );
}

The mistake to avoid is building @id from a relative path. `#organization` and `${SITE}/#organization` look equally correct in a template and only one of them works.

Astro

Same principle, in a layout component:

---
const { title } = Astro.props;
const SITE = Astro.site!.href.replace(/\/$/, "");
const graph = [
  { "@type": "WebPage", "@id": `${Astro.url.href}#webpage`, name: title,
    isPartOf: { "@id": `${SITE}/#website` } },
  { "@type": "WebSite", "@id": `${SITE}/#website`, url: `${SITE}/`,
    publisher: { "@id": `${SITE}/#organization` } },
  { "@type": "Organization", "@id": `${SITE}/#organization`, name: "Example Ltd" },
];
// `set:html` does not escape, so escape `<` for the same reason as above.
const json = JSON.stringify({ "@context": "https://schema.org", "@graph": graph })
  .replace(/</g, "\\u003c");
---
<script type="application/ld+json" set:html={json} />

Set site in astro.config.mjs so Astro.site is defined. Without it the identifiers silently become relative.

tangly

tangly emits the @graph shape on every page from docs.json. Set siteUrl, then seo.organization (name, url, logo, sameAs) or a root sameAs list, and every page’s @graph carries the same Organization and WebSite nodes under the same absolute @ids, with the per-page nodes referencing them by @id.

Without a resolvable site URL tangly emits no JSON-LD at all, which is better than a graph of relative identifiers but leaves the map empty.

Checking your work

Re-run the audit and look at the Entities section, or query the map directly:

squirrel audit https://example.com
squirrel entities --problem no-id
squirrel entities --problem split-identity
squirrel entities "https://example.com/#organization"

To see whether a change actually landed, compare the two audits:

squirrel entities --diff

The diff reports entities that gained an @id separately from additions and removals, so a successful identity fix shows up as a gain rather than as one entity disappearing and another appearing.

References

Type to search…

↑↓ navigate↵ openesc close