Using variables from external file in your Quarto project
Stop hardcoding! Learn how to easily manage and reuse variables in your Quarto documentation using external YAML files and environment variables.
This article is over a year old but was reviewed on July 30, 2026 — the content is still accurate.
This article is part of the Discovering Quarto series:
- Running Quarto Markdown in Docker
- Quarto conditional display
- Use Quarto and create a PowerPoint slideshow
- Using variables from external file in your Quarto project
- Some tips and tricks for Quarto when rendering as a reveal.js slideshow
- Quarto Callout Blocks
- Quarto includes short code
- Quarto Inline style
- My favorite Quarto extensions
- Using Mustache templating with Quarto
- Make your Quarto project Devcontainer-Ready — No More Setup Headaches
- Quarto - How I Built a Self-Documenting Ecosystem for 50+ Projects

This article shows how to avoid hardcoding recurring values (IPs, paths, emails) in Quarto documentation by storing them in a _variables.yml file and referencing them with {{< var xxx >}} short codes, or via {{< meta xxx >}} for document metadata. It also covers reading values from an .env file with {{< env xxx >}}, loaded through --env-file when rendering Quarto in Docker.
My use case is: I need to write some long, technical documentation where I need to provide some information like IP addresses of used servers, some paths to the application, configuration folders, ...
The normal way to do this is to just put information directly in the documentation and to make sure to update every occurrence in case of changes during the lifecycle of the application.
The best way is probably to use an external file where information is stored in a key-value form and, during the rendering process of Quarto, replace short codes by values.
What Quarto variables do for you
You write this in your Markdown source:
Version {{< var version >}} is a minor upgrade.
Please contact us at {{< var email.info >}}.
And this is what Quarto renders:

The version number and the email address now live in one single file. Change them there, re-render, and every page of the documentation is up to date — including the twenty places you'd have forgotten.
All it takes: a _variables.yml holding your key-values, a _quarto.yml (which may be empty), and the {{< var >}} / {{< meta >}} short codes in your text.
Setting it up
Docker image with Quarto
If you don't have yet a Docker image with Quarto, read this article Running Quarto Markdown in Docker.
You can find the official documentation on https://quarto.org/docs/authoring/variables.html.
Here is how to proceed:
- First, it's mandatory, you should have a file called
_quarto.ymlin the same directory as the file (let's saydocumentation.md) you will convert using Quarto. Note: that file can be empty (see https://github.com/quarto-dev/quarto-cli/issues/2918 for more information on this). - Then you should create a file called
_variables.ymlwith your key-values and, finally, - You need to have your markdown file.
So, _quarto.yml can stay empty. Its presence is just to tell Quarto the Markdown file is part of a project.
Here is an example of what can be a _variables.yml content:
version: 1.2
email: info: info@example.com support: support@example.com
engine: jupyter: "[Jupyter](https://jupyter.org)" knitr: "[Knitr](<https://yihui.name/knitr>)"This is a configuration file that defines version information, sets up email addresses for different purposes, and maps rendering engine names to their display names with documentation links. It's the kind of file you'd use to centralize settings that your application references throughout its codebase.
And here is a Markdown example (file documentation.md):
---
title: Testing of variables short code.
---
{{< meta title >}}
Version {{< var version >}} is a minor upgrade.
Please contact us at {{< var email.info >}}.
Quarto includes {{< var engine.jupyter >}} and
{{< var engine.knitr >}} computation engines.
As you can see, the short code is something like {{< meta xxx >}} or {{< var xxx >}}.
meta is for metadata of the document like its title and var to retrieve information from _variables.yml.
Render it with quarto preview documentation.md --to html and you get the page shown at the beginning of this article.
Environment variables
You can also retrieve environment variables using {{< env xxx >}} but, there, you should first load these variables in case of need.
For instance, you can have a .env file like this:
APPLICATION_NAME=My application name
VERSION_NUMBER=1.2
This script sets up two configuration variables that store the name and version number of an application. These values would typically be used elsewhere in the script to identify or version the software being deployed or run.
Then, before calling the Quarto rendering process, you should load the file. Since I'm using Docker, I do this like this:
Here is the content of documentation.md:
---
title: Testing of variables and env short codes.
---
:::{.callout-tip}
## Environment variables
{{< env APPLICATION_NAME >}} v.{{< env VERSION_NUMBER >}}
:::
{{< meta title >}}
Version {{< var version >}} is a minor upgrade.
Please contact us at {{< var email.info >}}.
Quarto includes {{< var engine.jupyter >}} and
{{< var engine.knitr >}} computation engines.
I'm thus using --env-file .env in the docker run instruction so Docker will load my variables and make them available in the container. Quarto can then access them.

This solution is even better if you have an application such as Laravel, and therefore already have such an .env file. As a result, you reuse the same values for both the application and the documentation.
Conclusion
Variables are the right tool when what repeats itself is a value: a version number, an IP, a support address, a path. They cost two files and pay for themselves the first time a server is renamed.
When what repeats itself is a whole page structure rather than a value, variables are no longer enough — that's where Using Mustache templating with Quarto takes over.
This article is part of the Discovering Quarto series:
- Running Quarto Markdown in Docker
- Quarto conditional display
- Use Quarto and create a PowerPoint slideshow
- Using variables from external file in your Quarto project
- Some tips and tricks for Quarto when rendering as a reveal.js slideshow
- Quarto Callout Blocks
- Quarto includes short code
- Quarto Inline style
- My favorite Quarto extensions
- Using Mustache templating with Quarto
- Make your Quarto project Devcontainer-Ready — No More Setup Headaches
- Quarto - How I Built a Self-Documenting Ecosystem for 50+ Projects





