Skip to content

Fix notebook preview files missing from _site when rendering outside the project - #15009

Merged
cderv merged 8 commits into
mainfrom
fix/notebook-preview-outside-project-cwd
Oct 9, 2026
Merged

cderv merged 8 commits into
mainfrom
fix/notebook-preview-outside-project-cwd

Conversation

@cderv

@cderv cderv commented Oct 8, 2026

Copy link
Copy Markdown
Member

When a website with embedded notebooks is rendered from a directory other than the project directory (quarto render proj/index.qmd or quarto render proj from the parent), _site/index.html links to a notebook preview page that is not in _site. The same goes for the downloadable notebook source and the figures of the preview. Rendering from inside the project works. This is not a regression: it behaves the same in 1.4, 1.10 and 1.11.

Root cause

The notebook previewer returns its supporting files as project-relative paths, but the HTML post-process contract expects absolute ones (HtmlPostProcessResult in src/format/types.ts). The render pipeline resolves relative entries against the working directory, so they are dropped unless the working directory happens to be the project directory. Files that are not moved to the output directory are then deleted by the notebook context cleanup. The project-relative handling comes from an earlier path fix that had no test coverage.

Fix

The previewer now passes absolute supporting paths, and emplaceNotebookPreviews only relativizes resource entries that are absolute, since relative ones are already project-relative.

New smoke tests render the site from outside the project for both an .ipynb and a .qmd embed source, and check that the preview page, notebook source and figures reach _site. testSite now also removes the project .quarto directory so a cached state from one render cannot change a later one.

Fixes #15004

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.

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

cderv added 6 commits October 8, 2026 12:20
…the project directory

The notebook previewer forwarded project-relative supporting and resource paths, but the render pipeline expects absolute paths and resolves relative ones against the working directory. They were dropped unless the working directory was the project directory, so the preview page and the downloadable notebook source never reached the output directory.
… the project

The preview page and notebook download reach _site through the rendered notebook's href path, so the existing assertions passed even when supporting files were dropped. The figure directory only arrives through the supporting files, so asserting on it covers that half of the fix.
Relative resource entries are already project-relative, so joining them onto the project directory only to relativize them again was a round trip. Converting only absolute entries says what the code needs.
testSite removed only _site, so the project scratch directory survived between runs and a cached state from one render could change what a later render emitted. Removing it in teardown, after all verifications have run, matches what smoke-all does for project directories.
@posit-snyk-bot

posit-snyk-bot commented Oct 8, 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 2 commits October 8, 2026 18:02
The teardown hand-rolled existsSync plus Deno.remove for two directories; removeIfExists in src/core/path.ts already does that and is what other smoke tests use.
@cderv
cderv merged commit 2b13c21 into main Oct 9, 2026
51 checks passed
@cderv
cderv deleted the fix/notebook-preview-outside-project-cwd branch October 9, 2026 12:22
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.

Notebook preview page missing from _site when rendering a website from outside its directory

2 participants