Please consider the following.
I like to structure my R projects with different subdirectories. Using bookdown
or quarto
seems to make this quite difficult since both like to have their source files (.Rmd or .qmd) in the project directory. I was hoping that this will get easier with quarto
but this does not seem the case, although it should be possible according to this post.
Problem description (replicable example)
Start a new quarto book project in RStudio: File > New Project > New Directory > Quarto Book.
This will create several .qmd
files in the R project directory. Now create new subdirectories. Starting from the R project directory: scripts/qmd.
If we put all .qmd
files from the R project directory into scripts/qmd, we also need adapt their path in the _quarto.yml
(e.g., from index.qmd
to / scripts/qmd/index.qmd
).
After doing so and pressing the Render button, we receive the ERROR: Book contents must include a home page (e.g. index.md)
.
Putting only the index.qmd
file back into the R Project directory (and adapt the _quarto.yml
), the book can be rendered.
Question
.qmd
files into a dedicated subdirectory?Edit (ignore below)
Originally the below question was also asked but is now answered: quarto does not seem to have a "merge-knit" option like bookdown
(see here). This unfortunately makes quarto useless for my use case.
.qmd
files in the subdirectories? (setting execute-dir: project
as suggested here did not work for me.I'm assuming your purpose is just a specific personal preference for file organization.
You can have a large portion of your content in subdirectories (and that's my understanding of what Alison's blog post refers to), but you still need to have your index.qmd
in the root. For example, you can have a subdirectory for projects, another one for posts, another one for tutorials, like Alison does.
In any case, one way of achieving what you want is by using pre- and post-render scripts.
You could move all the files from the scripts/qmd directory before rendering and then move them all back afterwards.
pre-render: mv scripts/qmd/*.qmd .
post-render: mv *.qmd scripts/qmd
Incidentally, that doesn't match my own personal preference ;-)