Banner image: Photo © Cingular | Shutterstock

This document is based on teaching material originally developed for the Bren School of Environmental Science & Management’s Master of Environmental Data Science (MEDS) program. Check out Creating your personal website using Quarto, Customizing Quarto websites, and Adding a blog to your existing Quarto website for additional information and examples.

Quarto is a publishing system built on Pandoc that allows users to create dynamic content using R, Python, Julia, and ObservableJS (with plans to add more languages too!).
R users have long loved RMarkdown for combining prose, code, and outputs into single “knitted” documents. Quarto extends all of RMarkdown’s best features (plus many more!) to additional languages.
.rmd vs. .qmd files
If you’re already an avid RMarkdown user, great news! RMarkdown (.rmd) and Quarto Markdown (.qmd) files look super similar:
--- gates at the top of the document)There are some slight differences to be aware of:
output in .rmd vs. format in .qmd){r echo=FALSE}) in .rmd files, and written below code block braces following hash pipes, |# (e.g. |# echo: false) in .qmd files.rmd files (e.g. FALSE) and lowercase in .qmd files (e.g. false).rmd files and Render .qmd files to convert your work to your desired output type (e.g. .html)
They also look pretty similar when knitted/rendered. Below is a side-by-side comparison of a knitted .rmd file and a rendered .qmd file (both as .html files):


Art by Allison Horst. Be sure to check out the rest of Allison’s seriously cute Quarto penguin art in the #rstudioconf2022 keynote talk, Hello Quarto, by Julie Lowndes & Mine Çetinkaya-Rundel!
You can explore Quarto’s documentation to learn more about creating documents, websites, blogs, books, slides, dashboards, etc.
To follow along, you’ll need:
Please refer to the MEDS Installation Guide for detailed setup instructions (follow steps 1-7).
This section reviews the “create remote (i.e. GitHub) repo first, then clone repo to your local machine to add Quarto website scaffolding files second” workflow. If you need / want to instead use the create a local repo with Quarto website scaffolding files first, then create upstream remote (GitHub) repo second workflow, check out these instructions.
Navigate to the GitHub profile or organization where you want your website repository (repo) to live (this will likely be the OHI-Science GitHub organization, but certainly doesn’t have to be).
Create and clone a GitHub repository following the instructions, below. Importantly, choose your repo name carefully, as it’ll become a part of the website’s URL, once deployed (e.g. a repo named my-awesome-repo that lives in the OHI-Science organization will have a base URL, https://OHI-Science/my-awesome-repo).
Create a GitHub (aka remote) repo:
.gitignore (we can add these later). Click Create repository.
Clone your repo:
_quarto.yml, .gitignore, index.qmd, about.qmd, styles.css):quarto create-project --type websitequarto preview in your RStudio Terminal. This will launch a preview of your website in a browser window. So long as you leave the preview running, it will update each time you make and save changes to website files (which makes iterating on your work really easy!). By default, your repo name (here, my repo name is OHI-methods-EXAMPLE) will appear as both your navbar and landing page titles, alongside some other placeholder text. A second navbar page, titled “About”, is created for you as well.
Previewing our website in the browser by running quarto preview in the RStudio Terminal
When you create a new Quarto website, a handful of files are generated by default:
index.qmd renders your website’s landing page. Whatever you add to this file will be the first content visitors see when they visit your site. Update the content of index.qmd (or any other website page) using markdown and / or HTML (you can mix and match both on the same page), add and execute code chunks and embed outputs, etc.index.qmd
This is the default / expected name given to website landing / home pages. If you change the name of this file, you risk breaking your (eventual) deployment.
about.qmd is a regular ’ole website page. You’re able to change both the name of this file (e.g. change about.qmd to my-new-name.qmd) and / or the title of the file by updating its YAML – by default, the YAML only includes a title:about.qmd
---
title: "About"
---YAML is a human-readable data serialization language, which is commonly used for creating configuration files. Quarto recognizes lots of different YAML options for controlling the appearance and behavior of your individual website pages. YAML is always written at the top of a .qmd file and is denoted by a pair of “gates”, ---.
_quarto.yml is your website configuration file. Any document rendered within your project directory will automatically inherit the metadata defined in this project-level configuration file (though you can control metadata on a page-by-page basis by making edits to an individual page’s YAML, which will override any options specified in _quarto.yml). Importantly, this is where you define your website’s structure (e.g. your navbar, sidebar, footer, etc.). By default, your file should look similar to this:_quarto.yml
project:
type: website
website:
title: "OHI-methods-EXAMPLE"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd
format:
html:
theme: cosmo
css: styles.css
toc: truestyles.css is a stylesheet, where you can write CSS rules to alter the appearance of your website. We’ll actually create and use a different type of stylesheet (called a “sassy css file”, .scss) in a bit.
.gitignore is a place where we can specify any files that we don’t want Git to track (i.e. that we want Git to ignore). This is not a “Quarto thing,” but rather a valuable file that lives inside git directories. One common use is to add any large data files that you don’t want to accidentally push to GitHub (GitHub isn’t designed to handle LARGE files).
The _site/ directory is where all of your rendered HTML (and other important) files live. When you render your site, Quarto takes all of your .qmd files and converts them to .html files, and saves them to this folder (which is important because web browsers don’t know how to read .qmd files, but do know how to read .html files). We’re actually going to change the name of this folder once we configure our website for deployment, but _site is the default name that Quarto uses (we can leave as-is, for now). You don’t want to physically edit or move any files inside this directory (if you want to make a change to your website, update the .qmd or _quarto.yml file, then re-render).
_quarto.yml configurationsThe _quarto.yml file is a place to make lots of additional updates to website appearance / configurations. Here, we’ll review just a few places to make easy and valuable updates, but be sure to check out the Quarto documentation for additional available tooling options.
index.qmd) before continuing on!
Before we make updates to _quarto.yml, let’s add some background information to our landing page, index.qmd (the below text was copied directly from Ocean Health Index 2022: Methods). We can also update our page title to something more informative than our repo name (which is set by default):
---
title: "Ocean Health Index 2024: Methods"
---
## Introduction to the global Ocean Health Index (OHI) assessment
The global Ocean Health Index assesses ocean health for 220 coastal countries and territories and has been conducted every year starting in 2012. The Index describes how well we are sustainably managing 10 goals for ocean ecosystems which represent the full suite of benefits that people want and need from the ocean. These goals include: artisanal fishing opportunity, biodiversity, carbon storage, clean waters, coastal livelihoods and economies, coastal protection, food provision, natural products, sense of place, and tourism and recreation. Each goal is given a score ranging from 0 to 100, and the full suite of goal scores are then averaged to obtain an overall index score for each region.
For more information about the philosophy of the Ocean Health Index and model development see Halpern et al. (2012, 2015) and <http://ohi-science.org/ohi-global/>, which includes information about downloading global ocean health data.The website should look similar to this, when previewed:

Our new landing page, with an updated title and text.
A few adjustments to our _quarto.yml can improve our website’s appearance:
_quarto.yml
project:
type: website
website:
sidebar:
1 title: "OHI Methods (2024)"
style: "docked"
search: true
contents:
- href: index.qmd
text: Home
- regions.qmd
- section: Models
contents:
- index-scores.qmd
- goal-scores.qmd
- section: Likely future status dimensions
contents:
- trend.qmd
- pressure.qmd
- resilience.qmd
- references.qmd
format:
html:
theme: cosmo
css: styles.css
2 toc: false
3 page-layout: fulltitle
toc: true in the YAML of individual .qmd files)
After these three small updates, our website now looks like this:

Quarto supports images in the navbar / sidebar (though note that getting the sizing correct in a navbar can be a bit tricky and may require writing some CSS). Provide an image to the logo option in _quarto.yml.
You can download the OHI logo, but also feel free to practice using any image you have easily accessible.
_quarto.yml
project:
type: website
website:
sidebar:
1 # title: "OHI Methods (2024)"
2 logo: media/OHI-logo.png
style: "docked"
search: true
contents:
- href: index.qmd
text: Home
- regions.qmd
- section: Models
contents:
- index-scores.qmd
- goal-scores.qmd
- section: Likely future status dimensions
contents:
- trend.qmd
- pressure.qmd
- resilience.qmd
- references.qmd
format:
html:
theme: cosmo
css: styles.css
toc: false
page-layout: fullmedia/
There are a lots of options to publish your website. We’ll use the GitHub Pages option, which allows you to publish a website from any GitHub repository. To do so, there are a few configuration steps:
Create a file named .nojekyll in your repository’s root directory (e.g. OHI-methods-EXAMPLE/), which is required to disable some processing of HTML files that GitHub does by default. There are two ways you can do this:
touch .nojekyll.nojekyll..nojekyll file)
The touch command can be used to create a new, empty file from the command line. Similarly, RStudio’s Text File button allows you to define and create any file type. Since there’s no default button in RStudio for creating a .nojekyll file, you’ll want to use one of these two approaches.
.nojekyll is a hidden file which won’t visibly appear in your directory. You should see it show up as a file to track with git (either under the Git tab in RStudio, or when you run git status in the command line). You can also view hidden files in Finder (Mac) using the keyboard shortcut Command + Shift + ., or follow these instructions for Windows 10, 8.1, and 7.
output-dir in your _quarto.yml file to docs (it’s easiest to open and edit this from RStudio):_quarto.yml
project:
type: website
output-dir: docs
# ~ additional metadata excluded for brevity ~output-dir (here, that’s the docs/ folder)
The output-dir is the directory (i.e. folder) where your rendered .html (and other important) files will automatically be saved to when you “Build” your website (see the next step!) – that is, when you convert all your .qmd files to the .html files that your web browser can interpret / display.
_site/ if it exists and if you’re publishing with GitHub Pages
If you previewed or built your site before setting output-dir to docs in _quarto.yml, you’ll notice a _site/ directory inside your repository – this is the default output directory name. Because GitHub Pages will expect a docs/ folder to deploy from, you can delete _site/ altogether (and push your deletion, if you’ve already committed / pushed _site/ to GitHub).
quarto render in the Terminal) – this command creates the final version of your website documents for deployment. Once rendered, you should see your soon-to-be website appear in the Viewer tab.If you don’t see the Build tab, close then reopen your project. It should appear!

Clicking Render Website in the Build tab (or running quarto render in the Terminal) is a necessary pre-(re)deployment step – it converts all .qmd files to .html and ensures that all website components are stitched together correctly. If you do not render your website before pushing your files, your changes will not deploy.
Send all of your website files from your local git repository to your remote GitHub repository:
git add . command used in the Terminal for staging all files)git commit -m "my commit message")git push).Configure GitHub pages to serve content from the “docs” directory by clicking on the Settings tab in the top menu bar, then the Pages tab from the left-hand menu bar. Make sure that Branch is set to main and that the selected folder is set to /docs. Click Save. Once deployed (this may take a few minutes), your website’s URL will appear inside a box at the top of the page (you may have to try refreshing a few times).


See deployment status, time of each deployment, and how long it took to deploy each run. You can also find failed deployments here (yes, it does happen on occasion) and take action on fixing them.

You’re now ready to continue iterating on your website and redeploy with ease! Your workflow will look something like this:
quarto render in the TerminalThere are a number of ways to update a Quarto website’s theme (e.g. colors, fonts), but the (arguably) fastest and easiest way to get started is by defining some Sass variables in a .scss file (stylesheet), then linking to that stylesheet in your _quarto.yml metadata. The steps below offer a “quick start guide approach,” though I recommend checking out these workshop materials on customizing Quarto websites using Sass & CSS for a much more thorough / deeper dive.
.scss file / stylesheetCreate a styles.scss file in your repo’s root directory (you can name it however you’d like), using the command touch styles.scss in the Terminal, or by Blank File > Text File > typing styles.scss from the RStudio Files pane.
Add the /*-- scss:defaults --*/ region decorator to the top of styles.scss (required by Quarto) – you’ll write all your Sass variables underneath this:
styles.scss
/*-- scss:defaults --*/styles.scss stylesheet to your website using the theme option in _quarto.yml:_quarto.yml
project:
# ~ additional YAML omitted for brevity ~
website:
# ~ additional YAML omitted for brevity ~
format:
html:
1 theme: styles.scss
toc: false
page-layout: fullstyles.scss stylesheet using the theme option
css: styles.css from _quarto.yml
This tutorial doesn’t cover writing CSS, though you can (and should) write any CSS in your .scss file (rather than writing it in a separate .css file). I recommend removing styles.css from _quarto.yml. You can also delete styles.css from your repo (you can always create a new one if you decide you want / need a .css file in the future).
$variable-name: value; (you get to decide what these variable names are!). Here, we define three colors:styles.scss
// Colors
$baby-blue: #E3F1F2;
$dark-blue: #252D5C;
$orange: #F26C25;// for single line comments in .scss files
You may also create multi-line comments, which start with /* and end at the next */.
styles.scss
/*-- scss:defaults --*/
// Colors
$baby-blue: #E3F1F2;
$dark-blue: #252D5C;
$orange: #F26C25;
// Sass vars
$body-bg: $baby-blue;
$body-color: $dark-blue;
$link-color: $orange;
$footer-bg: $dark-blue;
Your newly styled site should look similar to this (be sure to run quarto preview in the Terminal, if it’s not already running).
<style> </style> tags (starting with @import and ending with ;) to your clipboard.
styles.scss (I always place this at the top of my stylesheet, beneath /*-- scss:defaults --*/):styles.scss
/*-- scss:defaults --*/
// Import Google fonts
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');
// Colors
$baby-blue: #E3F1F2;
$dark-blue: #252D5C;
$orange: #F26C25;
// Sass vars
$body-bg: $baby-blue;
$body-color: $dark-blue;
$link-color: $orange;
$footer-bg: $dark-blue;mainfont option in _quarto.yml – this is the easiest way to use a single font across your entire website:project:
# ~ additional YAML omitted for brevity ~
website:
# ~ additional YAML omitted for brevity ~
format:
html:
theme: styles.scss
toc: false
page-layout: full
1 mainfont: Nunito
Our updated website, with Nunito applied.
But this requires a bit more Sass and CSS. While we won’t get into that here, check out these workshop materials and some “in the wild” examples (e.g. like the stylesheet for this very instructional document ).
GitHub Pages will then rebuild and redeploy your site at your URL.
Banner image: Photo © Cingular | Shutterstock