-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative links for images outside of presentation folder successfully preview, but break on render #131
Comments
I don't know if there is a shift as I think this has always be the case. When rendering a single document, the linked used in Markdown image for example will be relative to the rendered directory. If you use tools to get it from a 'project' root (like Try running Without this, only the web server was started at the subfolder level for the HTML in the subfolder, and I hope this is clear.
When adopting this strategy, you need to really about projects for sources and outputs you produce. First of all, you should really consider using Quarto projects if you want to manage your .qmd as a project. Currently in your RStudio cloud example, this is only a RStudio project, which is not the same. When using Project, Quarto will know a So if you add a project:
type: default Now you can render the document in subfolder, and you should see image. You should also be able to path like this starting with a ![](/images/llama.png) which means "relative to project root". Which avoid doing
This should not be useful for image path IMO. This options for knitr is quite advanced, and allow to change the working directory from which knitr chunk are evaluated. If this is only a filepaths problem, using
Yes this and other Quarto projects of type Website or Manuscript will do some copying of results into a So overall, try to use Quarto Projects, and then see if there is still some undesired behaviors. Hope it helps. |
Amazing! Thank you. I've left the original project as-is, but for any future readers, I've created an updated project that incorporates the fix https://posit.cloud/content/6927922, so you can see the change. For novices like me: Option 1: You can do the fix just as Cristophe says, create a new Quarto Project, and in the automatically-generated
Option 2: You can implement the fix without needing to start a Quarto Project from scratch. In your a RStudio Project, you can just click "new blank file" --> "text file", and name it |
Not sure whether this belongs in quarto-cli
There seems to be an intentional shift in Quarto to use relative instead of absolute paths. In particular, these paths are relative to the .qmd file.
This may have produced a behaviour where images are not rendering properly if they lie outside of the same folder as the .qmd file. The images will correctly display as part of the automatic 'preview' in the source pane, but when the document is rendered, it returns the broken image icon in its place.
This is even the case if we were to use
here::here
orxfun::from_root
. Using these functions work for sourcing external r scripts that follow the same directory structure, so seems to be something special with images. Using theexecute-dir: project
option does not seem to resolve the issue.This issue has been brought up in the community postings by John Graves, and Andy Field.
I have copied and modified a Posit Cloud project from Jon Graves' post demonstrating the behaviour: https://posit.cloud/content/6847700. There are three qmd files: one that works (at the project root), and two that don't work (in the presentations folder).
This may be relevant to discussions in the renderthis package, although their concern seems to be placing rendered output in a separate directory, not sourcing files.
There also seems to be some discussion about making changes to how Quarto uses absolute vs. relative paths. The practice of specifying directories has also been discussed in quarto-r issue #81, where @cderv mentions the potentially evolving nature of how quarto handles outputs, inputs, and resources.
Resolving this issue will help those of us that might want to use a pool of shared images across many different reports, whether across different lectures, or different report formats (e.g., posters, manuscripts, presentations). Addressing this may also resolve quarto-r issue #94 posted by aputron.
The text was updated successfully, but these errors were encountered: