Create a static site

Build a static site using Quarto in just 10 minutes
Author

Ludovic Deneuville

General principle

With Quarto, it’s very easy to create a static site containing HTML pages, slides, executed Python or R code, notebooks, pdf files…

It only takes 10 minutes to get a first result, perhaps a little more the first time.

  • You define Quarto setup
  • You write your content in .qmd files with markdown language
  • Quarto will generate the site’s html pages from these .qmd files

1 Local use

You will need the following tools to work locally :

1.1 Create a Quarto project

You can read official documentation or simply follow these advices

To create a Quarto projet you will need the following files :

File Description
_quarto.yml Project Metadata
index.qmd Home page
styles.css CSS file for styling the project
Tip

We strongly advice you to also create a folder named doc to store your content in a clear tree structure.

Example of trees:

1.2 Metadata

1.3 Create your index

    • It will contain some metadata (title, description, author…) and then your content in markdown language
---
title: "My home page"
description: "Description of my home page"
author: "Ludovic Deneuville"
format: html
from: markdown+emoji
---

## My content

my content using Markdown language

1.4 Create pages

Tip

If you want more markdown content, feel free to see code of files in the Examples section, such as Practical

1.5 Play with styles

    • you can let it empty for now

1.6 Render

Congratulation

🎉 you created your first quarto website!

2 Deploy with GitHub pages

2.1 Create a repository

2.2 Clone your repository

  • /.quarto/
    /_site/ 
  • ├── .github/
    │   └── workflows/
    │       └── publish.yml
  • on:
      workflow_dispatch:
      push:
        branches: main
    
    name: Quarto Publish
    
    jobs:
      build-deploy:
        runs-on: ubuntu-latest
        permissions:
          contents: write
        steps:
          - name: Check out repository
            uses: actions/checkout@v4
    
          - name: Set up Quarto
            uses: quarto-dev/quarto-actions/setup@v2
    
          - name: Render and Publish
            uses: quarto-dev/quarto-actions/publish@v2
            with:
              target: gh-pages
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Note

The .github/workflows/publish.yml file contains the list of actions required to deploy the site.

Example of Quarto-tuto

    • A github pipeline is triggered by a push

A few minutes later, the site will be available on https://<username>.github.io/<repository_name>

3 Python Setup

Note

If you want to execute Python code in your qmd files.

3.1 Local

3.2 Remote

  •     - name: Install Python and Dependencies
          uses: actions/setup-python@v4
          with:
            python-version: '3.10'
            cache: 'pip'
        - run: pip install jupyter
        - run: pip install -r requirements.txt

4 R Setup

Note

If you want to execute R code in your qmd files.

4.1 Local

4.2 Remote

  •     - name: Install R
          uses: r-lib/actions/setup-r@v2
          with:
            r-version: '4.3.0'
    
        - name: Install R packages from DESCRIPTION file
          uses: r-lib/actions/setup-r-dependencies@v2