Output directory in quarto-cli not respected?

Hi all,
I am terying quarto as a replacement for my Rmd-based rmarkdown::render workflow to render reports into specific folders. The usual project structure has the Rmd files in a scripts folder and then I render them to specific results folders :

project_base:

  • scripts/
    • hello.Rmd
  • results/
    • reports/
      • hello.html

I do this with:

rmarkdown::render(
  "scripts/hello.Rmd",
  output_dir = "results/reports"
)

Trying to recreate this in quarto-cli with a simple example, I thought thought the way to go was the option --output-dir:

quarto render scripts/hello.qmd --output-dir report/

However this places all outputs in the same directory as the qmd file (scripts/) and not in the output-dir:

ls scripts/
hello_files  hello.html  hello.qmd

Is this the expected behaviour? Is there a way to replicate the rmarkdown::render(output_dir = "dir") behaviour?

Cheers-

1 Like

I've had the same problem specifying the output-dir: option in the _quarto.yml file. Keeping code in separate folder is important so that I can ensure only code gets uploaded to github, whereas outputs get ignored. It's inconvenient to add a *_files/ to my .gitignore as opposed to my output/ covering everything in the output folder.

@Rory_OG I totally get it. That is also a reason why I keep most of my reports away form the scripts.

I had a tip on twitter that --output-dir would work inside a "Quarto project". So I created the project with quarto create and then rendered my script with quarto render scripts/hello.qmd --output-dir results. It sort of works, but the output is sent to "results/scripts/".

So my conclusion is that for now I will stick to rmarkdown::render and tell my pythonista colleagues to use quarto for simpler use cases and testing, but not for production yet.

I spent a lot of tome yesterday and today researching different approaches. I ultimately opted to keep the reports in the root directory and use a combination of:

output-dir: output  
post-render: xcopy *_files output 

to get the html and the supporting files moved into the output folder. For some reason, output-dir hasn’t been moving the supporting files so I found the shell command as a work around.

This is an interesting discussion. Could you open a discussion about this in Quarto repo directly ?

--output-dir is indeed working differently than in rmarkdown::render(). It will work for Project only, and is used to change the default output folder.

This is expected as your Qmd document is in a scripts subfolder, the results will also be in a same name subfolder as it would be expecting for Quarto project like websites or books. This is how it works.

@adomingues t seems you have another use case to change where the output of a single document are stored. Currently, I don't think there is a flag for that in quarto render. This would be worth discussing for a feature request. For now, using post-render script as shared by @Rory_OG would be the way .

1 Like

Sure thing, I’ll add it in. I created an issue for this a couple weeks ago and was told this is the expected behavior and that it’s quite complicated to deal with .qmd files being stored in subdirectories without the output dir also containing that subdirectory in the new path.

Hopefully this technique and some .gitignore safeguards will be a solid workaround for the time being.

1 Like

Thank you for the reply @cderv and I started the discussion Output directory in quarto-cli · Discussion #2171 · quarto-dev/quarto-cli · GitHub

It took me while to get around but I am looking forward to see if this feature request gets picked up by the quarto team.

1 Like

This topic was automatically closed 7 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.