Configuring a Quarto website


Setting up a Quarto website is not trivial. In this post, I discuss how to setup the _quarto.yml configuration file optimally.


March 31, 2024

1 Quarto website configuration

Quarto offers a lot of configuration options for html and also for websites! In this post, I focus on the configuration options I believe to be the most important. These are, of course, a reflection of my personnal priorities, but I hope it can serve as a stepping stone towards your own mastery of Quarto.

Remember that all of these options can be modified on a document-by-document basis by modifying the yaml header of the .qmd file.

2 My choices

Here is my current global settings file with comments. Check out the latest version here.

1    type: website
    output-dir: docs
        - CNAME

    title: "Guillaume Dehaene"
2    page-footer: "This website was created with [Quarto]("
3    page-navigation: true
    back-to-top-navigation: true
            - blog.qmd
            - publications.qmd
            -   href: about.html
                # file: about.qmd
                text: About me

4        theme:
            - cosmo
            - style.scss
        mainfont: "EB Garamond, Georgia, serif"
        monofont: Fira Code, consolas, courier, monospace
        highlight-style: github

            method: mathjax
            url: ""
            text: |
                @import url(',wght@0,400..800;1,400..800&display=swap')
                @import url('')
5                MathJax = {
                    tex: {
                        tags: 'ams'  // should be 'ams', 'none', or 'all'
6                    output: {
                        font: 'mathjax-fira'
7        toc: true
        toc-location: right-body
8        number-sections: true
        number-depth: 3

9        shift-heading-level-by: 1
        anchor-sections: true

10        code-copy: true

11        code-tools: true

12        freeze: auto

13        link-external-icon: true
        link-external-newwindow: true

14        lang: en

15        strip-comments: true
Publishing to github pages using this method.
A simple footer which I’ll need to improve latter.
Add page navigation information.
Styling options. See my blog post on how I built the styling.
Number (almost all)1 all math equations.
Styling options. See my blog post on how I built the styling.
Including a toc menu:
Numbering sections, more or less like a Latex document. Headers from # to ### get numbered.
Adding an anchor symbol to headers. This is purely about communicating to the user that they can link to headers. shift-heading-level-by: 1 is necessary here. It converts # titles to <h2> instead of <h1>. <h1> elements do not receive the anchor treatment.
Add a “copy code” anchor to code blocks. Another nice user-facing feature.
Add a button to view the Quarto markdown source of each document. This is not a super useful feature but it has no downside.
Avoid repeating Python calculations to decrease document rendering time.
Add additional styling to make obvious to the user which links are external and open these in new windows / tabs.
Use english language for automated language construction.
Remove html comments from the source. Any comment I write are about the Quarto content, and are not relevant for the HTML document.

3 Page-specific options

These settings get applied globally accross the website, but they are not appropriate for special pages. Thankfully, we can override the global parameters on a given by giving them another value in the yaml header.

I’ve used this feature to customize the settings on the about.html page.

anchor-sections: false
number-sections: false
code-tools: false

This page has a very different type of content. Numbering sections, anchoring all sections, and providing the page source are all features which distract from that content. Interestingly, some features are automatically removed just by using the about page format.

4 Other interesting options

These options are presented in the order in which they appear in the Quarto docs:

  • smooth-scroll: instead of jumping to the target anchor, scroll the page smoothly. I feel that this improves the wow factor of the website, but it can also be annoying. It’s definitely a matter of personnal preference.
  • html-math-method: choose the math renderer. mathjax is the best as far as I’m concerned (especially with version 4.0 on the way) but you can try out the other options.
  • linestretch: more space between lines. Can be the right choice if you want to produce a document that a reviewer would print. That’s not really a website option though.
  • lightbox: Give a gallery scroller to the figures. I feel that this setting depends on the type of documents you write. For an article, I feel this should be on. I believe that Nature and several other journals use a similar type of styling for their figures.
  • crossref: if you want to customize the behavior of cross-references.
  • include-in-header, include-before-body, include-after-body: these commands inject html code or files in specific sections of the final document. If you need to do some advanced features, you probably need this.
  • copyright, license: the information gets added to the appendix of the document.
Back to top


  1. Equations can either be delimited by $$ $$ signs or an ams-delimiter (for example: \begin{equation} \end{equation}). This numbers all ams equations. I’ll have more to say about math in future posts.↩︎