Skip to content

Validate page-level open-graph and twitter-card options - #15084

Merged
cderv merged 6 commits into
mainfrom
fix/page-level-open-graph-and-twit
Oct 16, 2026
Merged

cderv merged 6 commits into
mainfrom
fix/page-level-open-graph-and-twit

Conversation

@cderv

@cderv cderv commented Oct 16, 2026

Copy link
Copy Markdown
Member

Follow-up to #15057, whose image description now sends users to page-level open-graph to declare the preview image size.

Page front matter open-graph and twitter-card are read by the website metadata postprocessor and merged with the website: options, as the website tools guide documents. The schema only declared them under website:, so at page level they got no validation and no editor completion. A misspelled option such as imge-width was silently ignored, and a value of the wrong type such as description: 42 crashed the render with TypeError: value.trim is not a function. The same mistakes under website: in _quarto.yml are reported with a "Did you mean" hint.

Fix

Declare both keys in document-website.yml, reusing open-graph-config and twitter-card-config, so a page accepts the same options as the website. An empty value (open-graph: with nothing after it) is accepted too: the postprocessor handles it, and the #12016 tests rely on it.

Note

A page or _metadata.yml with an unknown option under open-graph or twitter-card used to render, with the option ignored. It now fails validation, as it already does under website:. The changelog entry says so.

The tests validate front matter strings against the real schema in a unit test, not with a smoke-all document per value, so another case is one more table row. The testing guidance in llm-docs/testing-patterns.md and .claude/rules/ now points schema changes to this kind of test. These tests load the generated yaml-intelligence-resources.json, not the .yml source, so dev-call build-artifacts has to run before they see a schema change.

The quarto.org format reference is generated from this schema, so it will list both options for pages at the next reference update.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, DeepWiki MCP
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

@posit-snyk-bot

posit-snyk-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

cderv added a commit that referenced this pull request Oct 16, 2026
cderv added a commit that referenced this pull request Oct 16, 2026
@cderv
cderv force-pushed the fix/page-level-open-graph-and-twit branch from ce28a71 to 57249f4 Compare October 16, 2026 10:43
cderv added 6 commits October 16, 2026 13:15
Page front matter `open-graph` and `twitter-card` are read by the website
metadata postprocessor and merged with the `website:` options, and the
website docs describe that use. The schema only declared them under
`website:`, so at page level a typo was silently ignored, and a wrongly
typed value such as `description: 42` crashed the render with
`value.trim is not a function` instead of a validation error.

The page entries reuse `open-graph-config` and `twitter-card-config`, so
both levels accept the same keys. They also accept null: an empty
`open-graph:` key is handled by the postprocessor and covered by the
Validating front matter strings against the real front-matter schema
checks each case in milliseconds, and a new case is one table row, where
the smoke-all documents needed a full render per option. The valid rows
guard against the page schema rejecting options the postprocessor reads,
including the empty value.
Whether a YAML option is accepted is a schema question; a smoke-all
document per value costs a full render each and grows with every option,
while a unit test against the real schema is one table row. The
schema-validation unit tests load the generated
yaml-intelligence-resources.json rather than the .yml source, so a test
run before build-artifacts silently checks the old schema; checked by
reverting only document-website.yml, after which the new test still
passed.
@cderv
cderv force-pushed the fix/page-level-open-graph-and-twit branch from 57249f4 to de89f53 Compare October 16, 2026 11:26
@cderv
cderv merged commit 0e28ab3 into main Oct 16, 2026
51 checks passed
@cderv
cderv deleted the fix/page-level-open-graph-and-twit branch October 16, 2026 12:24
cderv added a commit that referenced this pull request Oct 16, 2026
…of social metadata (#15091)

Pages read `bread-crumbs`, `back-to-top-navigation`, `page-navigation`,
`margin-header` and `margin-footer` from their own front matter, but the
document schema only declared them under `website:`, so a wrong-typed
page value passed validation silently and editors offered no completion.
A page `open-graph: false` or `twitter-card: false` also still emitted
`og:` or `twitter:` tags when the site enabled them. The provider loop
skipped a provider only when both page and site values were falsy, and
the merge treats a page `false` like an unset value, so the site won.

- Declare the five page-level options in the document schema, with the
  same types as their `website:` counterparts
- Skip a social metadata provider when the page sets it to `false`; an
  empty page value still falls back to the site setting

Related to #15084
See quarto-dev/quarto-web#2297 for the page opt-out documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants