Can I change the Quarto working directory in one line?

The project structure looks like this:

root
├───image.png
└───quarto.qmd

In quarto.qmd, it has the following codes:

!["Image title"](./image.png)

Now I create a Quarto project, the file structure is changed to this:

root
├───script.R
├───image.png
└───quarto project
    └───quarto.qmd

I have 2 questions:

  1. Can I change the default working directory in quarto.qmd to ../ in just one line? There are so many of the image and I don't want to change them one by one everytime.
  2. Changing !["Image title"](./image.png) to !["Image title"](../image.png) somehow doesn't seem to work in a Quarto project. It seems to parse the path to root/.../image.png.

knitr::opts_knit$set(root.dir = '../') or

knitr:
  opts_knit:
    root.dir: "../"

seem to change only the code, not the image path.

Quarto project are meant to be the wider scope to use, meaning you can't really access some resources outside of the project, especially relatively (using ../quarto project).

So you won't be able to access images outside of the project. Basically, the answer is you can't change what a Quarto project means.

Why not use your root as the project ?

root
├───script.R
├───image.png
├───_quarto.yml
└───contents
    └───quarto.qmd

What drives the need to try change this ? If I can understand, I can probably give you advice on how to set up your project.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.