How to Publish a Quarto Website with GitHub Pages and Actions
This guide demonstrates how to create and publish a Quarto website using GitHub Pages and GitHub Actions, with automatic deployment so you never need to render files locally.
Prerequisites
- Git installed on your computer
- A GitHub account
1. Create a New Quarto Project
- Open RStudio and go to: File > New Project > New Directory > Quarto Website
- For Directory name, use the form:
- For a personal site:
username.github.io - For an organization:
organizationname.github.io
- For a personal site:
- Choose a folder to save the project locally.
- Make sure to check:
- Create a git repository
- Use renv with this project
- Click Create Project. This sets up your Quarto site with version control and reproducible package management.
2. Create GitHub Repository
- In GitHub, create a new repository.
- Name it exactly the same as your project directory (e.g.
username.github.io). - Make the repository Public (required for free GitHub Pages).
- Click Create repository.
Connect your local project to this repository:
- Copy the GitHub setup commands (shown after creating the repo).
- Open a terminal/Git Bash, go to your project folder, paste and run those commands.
- Add, commit, and push your files:
git add .
git commit -m "Initial commit"
git push3. Create the gh-pages Branch
- On GitHub, open the branches dropdown (where it says main).
- Click “View all branches”, then “New branch”.
- Name it
gh-pagesand create it.
4. Set Up GitHub Actions Workflow
- In your Quarto project folder, create the following structure:
.github/workflows/- Inside, add a file named
publish.yml
- Add this content to
.github/workflows/publish.yml(Taken from the official Quarto documentation)
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: Set up R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Restore renv snapshot
uses: r-lib/actions/setup-renv@v2
- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- Save the file.
5. Commit and Push Workflow File
git add .
git commit -m "Add GitHub Actions workflow"
git push6. Configure GitHub Pages
- On GitHub, open your repository settings.
- Go to Pages in the sidebar.
- Set the publishing branch to
gh-pages. Save.
7. Monitor Deployment
- In GitHub, open the Actions tab.
- You’ll see the workflow running automatically.
- Wait until all steps pass (green checkmarks).
- When complete, go back to Settings > Pages and find your published site link.
How It Works
- GitHub Actions installs R and Quarto, restores R package versions (
renv), renders your project, and deploys it—all automatically on every push. - No local rendering required: Just commit and push; GitHub builds and updates your website.
Tips & Troubleshooting
- The site will publish at:
- For personal sites:
https://username.github.io - For project sites:
https://username.github.io/repositoryname/
- For personal sites:
- If the workflow fails, check the Actions tab for error logs.
- Confirm your repository is public and the Pages branch matches the workflow output.
Guide adapted from Melissa Van Bussel and Quarto documentation, 2024.