Skip to content

Use the page's site-name for og:site_name and only update Quarto's own meta tags - #15102

Merged
cderv merged 2 commits into
quarto-dev:mainfrom
Masad791:bugfix/og-site-name
Oct 19, 2026
Merged

cderv merged 2 commits into
quarto-dev:mainfrom
Masad791:bugfix/og-site-name

Conversation

@Masad791

Copy link
Copy Markdown
Contributor

Description

Fixes #14917.

Both problems from the issue came from the markdown pipeline that runs after the social meta tags are written:

  • siteTitleMetaHandler always pushed the website title into og:site_name, so a page's open-graph.site-name never made it to the output.
  • the handlers found their tags with doc.querySelector, i.e. the first match in <head>, so a tag from include-in-header or an extension got rewritten instead of Quarto's own.

writeMetaTag now returns the element it creates, the post processor keeps the tags it writes by name, and the pipeline handlers update those elements directly instead of searching the head. og:site_name now gets the same value the first pass writes: open-graph.site-name when the page sets it, the website title otherwise. Tags Quarto didn't write are left alone, which covers og:title, og:description, twitter:title and twitter:description as well.

Tests: a small website project under 2026/10/19/issue-14917 following the issue's repro. index.qmd checks the page's site name wins, and about.qmd adds decoy tags for all five names through include-in-header and checks they keep their values while Quarto's tags get the right ones. Both fail on main and pass with this change.

I also ran the existing social metadata tests (27 smoke-all documents plus smoke/site/render-website-image-data-uri.test.ts). All pass except 2024/10/28/issue-10311, which needs Jupyter; it fails the same way on main on my machine.

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
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

…a tags

The markdown pipeline that renders social metadata overwrote og:site_name
with the website title, so a page's open-graph.site-name never reached the
output. It also looked the tags up with querySelector, which returns the
first match in the head, so a tag added through include-in-header or an
extension got rewritten instead of the one Quarto wrote.

writeMetaTag now returns the element it creates, the post processor keeps
the tags it writes by name, and the pipeline handlers update those elements
directly. og:site_name gets the same resolved value as the first pass:
open-graph.site-name when set, the website title otherwise.

Fixes quarto-dev#14917
@posit-snyk-bot

posit-snyk-bot commented Oct 19, 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 cderv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Keeping the elements Quarto writes is the right fix I think. The markdown pipeline pass is what resolves markdown and shortcodes in the site title, so it can't be dropped, and nothing in the output marks which tags Quarto wrote, so a narrower selector would not work.

I can reproduce the issue on main and the PR fixes it, also for a page site-name with markdown or a shortcode, and for one set in _metadata.yml.

I'll push a few small adjustments on your branch before merging, no need to change anything on your side.

… out of social metadata

The changelog entry moves into issue number order with the author attribution.

A page with `open-graph: false` that writes its own tags had them rewritten with the website title before this fix, so it gets a test.

`metadataHtmlPostProcessor` drops its unused default map and the `written.clear()` call, since its only caller creates a fresh map for each file.
@cderv
cderv merged commit 6872bdc into quarto-dev:main Oct 19, 2026
51 checks passed
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.

Website og:site_name ignores open-graph.site-name, because the site-title handler overwrites the first matching meta tag

3 participants