Skip to content

fix(schema-org): let the canonical link set the graph url (v2) - #994

Open
harlan-zw wants to merge 5 commits into
v2from
fix/v2-schema-org-canonical-url
Open

harlan-zw wants to merge 5 commits into
v2from
fix/v2-schema-org-canonical-url

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Backport of #993.

Merge after #992. Both edit the canonical branch in packages/schema-org/src/plugin.ts, so once #992 lands this needs v2 merged in.

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Same bug as main: resolveMeta rebuilt url from host and path, so neither the page <link rel="canonical"> nor an explicit url (or the deprecated canonicalUrl) reached WebPage url or @id. The page url now comes from an explicit url, then the canonical, then host + path, with the same decisions as #993: a cross-domain url changes only WebPage.url while ids stay on the site host, query strings are kept, and an explicit url ignores trailingSlash.

ResolvedMeta gains path (already present at runtime) and idUrl. The plugin config is no longer pre-resolved, since that filled a default url that would outrank the canonical.

Behaviour change

An explicit url or canonical with a query, a trailing slash that differs from trailingSlash, or another host now shows in WebPage.url. ResolvedMeta gains idUrl, and its type now declares path. See #993.

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

Backport of #993. resolveMeta rebuilds the url from host and path, so the canonical href never reached WebPage url or @id. The harlanzw bench fixture declares a / canonical with a /path route, so its WebPage now follows the canonical.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 884d714c-3fdf-4bb5-b704-30de5939f27c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Backport of the #993 follow-up. An explicit url sets host and path and beats the canonical, so the bench fixture's explicit /path url wins again and its snapshot reverts.
nuxt-schema-org passes a host with a trailing slash or base path plus a url under it. Deriving host from the url origin dropped both and changed every graph @id, so a url under the current host now sets only the path.
A raw prefix check missed a url that differs from the host only in case or a default port, and then dropped the host base path.
Decisions from review: the url property follows an explicit url or canonical exactly, query and trailing slash included. Page @id values follow it only when it sits under the site host, so a cross-domain canonical cannot move node identity. trailingSlash shapes only the url built from host and path. Home page and page type checks read the path, since the url may now carry a query or another host.
@harlan-zw harlan-zw added harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Sep 29, 2026
@harlan-zw

harlan-zw commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

🤖 READY · 88/100

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. A person still decides the merge.

  • Merge gate: Passed.

  • Review gate: Passed. No finding above 80/100.

  • CI gate: Passed.

  • Logged (35/100): Deprecated position: 'head' plugin config no longer places the JSON-LD script in head; it now renders at bodyClose. View code

    • Ask an agent to verify and fix this finding
  • Logged (30/100): A host string that starts with http(s):// but fails URL parsing crashes resolveMeta with an uncaught TypeError when a relative explicit url or canonical supplies the path. View code

    • Ask an agent to verify and fix this finding

Selected findings run after merge and open separate pull requests.

@harlan-zw harlan-zw added harlan-agent-ready The automated Review passed every gate on this head commit. v2 and removed harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

harlan-agent-ready The automated Review passed every gate on this head commit. v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant