Deploy to GitHub Pages
Set up automatic deployment with GitHub Actions
Deploy to GitHub Pages
This guide shows how to automatically deploy your documentation to GitHub Pages.
Generate GitHub Actions Workflow
QuartoDocBuilder can generate a GitHub Actions workflow for you:
using QuartoDocBuilder
quarto_github_action()This creates .github/workflows/docs.yml.
You can override the defaults:
quarto_github_action(
quarto_version = "pre-release", # Quarto version (pre-release has Julia support)
julia_version = "1", # Julia version
output_dir = "site", # Quarto output directory
trigger_branches = ["main", "master"] # branches that trigger the build
)Workflow Contents
The generated workflow:
- Triggers on pushes (and PRs) to the configured branches
- Installs Julia and Quarto, caching Julia packages
- Runs
julia --project=docs docs/make.jlto build the Quarto project - Runs
quarto render - Uploads
docs/siteand deploys it to GitHub Pages (onmain/master)
name: Build and Deploy Documentation
on:
push:
branches: ["main", "master"]
pull_request:
branches: ["main", "master"]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- name: Install Julia dependencies
run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
'
- name: Build documentation (Julia)
run: julia --project=docs docs/make.jl
- uses: quarto-dev/quarto-actions/setup@v2
with:
version: pre-release
- name: Render Quarto site
run: cd docs && quarto render
- uses: actions/upload-pages-artifact@v3
with:
path: docs/site
deploy:
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@v4
id: deploymentEnable GitHub Pages
- Go to your repository Settings
- Click Pages in the sidebar
- Under “Build and deployment”, select GitHub Actions
- Push to
mainto trigger the first build
Custom Domain
To use a custom domain:
- Add a
CNAMEfile todocs/with your domain - Configure DNS records for your domain
- Enable HTTPS in GitHub Pages settings
Troubleshooting
Build Fails
Check the Actions log for errors. Common issues:
- Missing dependencies in
docs/Project.toml - Quarto rendering errors
- Julia compilation errors
Pages Not Updating
- Ensure the workflow completed successfully
- Check that
docs/site/is being uploaded - Wait a few minutes for GitHub to deploy
404 Errors
- Verify
output_dir = "site"in your config - Check that
_quarto.ymlis generated correctly