Skip to main content

Quarto includes short code

Learn how to use the Quarto includes short code to break down long documents into multiple, organized files, making your writing process easier.

· 3 min read
View raw
Christophe
Markdown, WSL and Docker lover ~ Insatiable curious.
Cet article existe aussi en français — lire la version française.

This article is over a year old but was reviewed on July 30, 2026 — the content is still accurate.

Quarto includes short code

⚡
TL;DR

This article shows Quarto's {{< include >}} short code, which lets you split a long document into several smaller Markdown files and merge them at render time by referencing their relative paths from a main .qmd file.

Using the Quarto includes short code, writing a long document can easily be broken down into several smaller ones.

includes splits a document into fixed chunks. When the repeated part is the same structure filled with different values, Using Mustache templating with Quarto and Using variables from external file in your Quarto project are the right tools.

Imagine the following main.qmd file:

# My thesis in Latin
{{< include chapter1.md >}}
{{< include chapter2.md >}}

This is a Quarto markdown document that serves as a thesis written in Latin. It uses Quarto's include syntax to pull in the content from two separate chapter files, assembling them into a single document.

Quarto will then merge the three files when you render main.qmd.

Docker image with Quarto

If you don't have yet a Docker image with Quarto, read this article Running Quarto Markdown in Docker.

Includes tag​

The tag is simple, you just need to specify the relative path to the file to include. Get in-depth syntax on the official documentation.

Result​

Running quarto render main.qmd --to html on the main.qmd file shown above merges the included files into one document:

Quarto includes

Here's what's actually inside each included file.

Here is some dummy content for chapter1.md:

## Chapter 1

Voluptatem minus labore architecto sed voluptas molestiae perferendis. Sed voluptatem ut amet at blanditiis sunt et exercitationem quidem. Vel id impedit dicta omnis repudiandae iure.

Expedita magni facere. Ullam non non sint qui provident. Ea beatae voluptatem pariatur. Et beatae error ea aut neque omnis pariatur rerum ut.

Ad aut nobis magni aut est dicta adipisci est. Quo reiciendis eum aut rem. Dolores sit magni non.

And for chapter2.md:

## Chapter 2

Iure repudiandae perferendis maiores dolorem consequuntur exercitationem suscipit.

Animi voluptatem est quia. Quia id optio. Architecto ut ipsa voluptas minima voluptate accusamus architecto.

Consequatur debitis et sunt eos quod qui unde aut.

Now, by running, f.i., quarto render main.qmd --to html, Quarto will merge these two files (and main.qmd) into the rendered page shown above.

What is a `.qmd` file?

For Quarto, the extension isn't very important: whether it's .qmd or .md, there's no difference in treatment.

On the other hand, it's probably more interesting for us to use the .qmd extension when using a Quarto-specific syntax, as is the case here.


Was this article helpful?
Did you try the steps in this article?