Including markdown files that are stored in another directory #2315
-
Caveat: apologies in advance if I've missed an existing discussion, I have tried to find one!! I have a library of markdown content that I'd like to pull into a Quarto presentation; this library exists in a different directory to the quarto presentation. I know that I can include the absolute/relative path to the file, but I would rather set the directory using a variable. Is there a way to either:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No, there isn't. As you've noticed, the
|
Beta Was this translation helpful? Give feedback.
No, there isn't. As you've noticed, the
include
functionality is pretty narrow. That's currently by design, because the semantics of inclusions are very confusing. Quarto used to do something only slightly more complex in terms of directory resolution and we had to revert the change because the behavior was very unintuitive.There is a general technique you can use, and that is to use root-relative ("absolute") paths, starting with a…/
. If you write{{< include /path/to/include.md >}}
then that path gets resolved relative to the project website, independently of the path of the current file. This allows you to create a subdirectory of useful snippets and then refer to them consistently.