Publishing
Session 6
Session Overview
Session 6: Publishing
- Publishing Options Overview
- Comparison of Quarto Pub, GitHub Pages, Netlify, and other hosting services.
- Understanding benefits and limitations of each platform.
- Choosing the right publishing method for different use cases.
- Quarto Pub and GitHub Pages
- Step-by-step Quarto Pub deployment workflow.
- Three methods for GitHub Pages: docs folder, quarto publish, and GitHub Actions.
- Understanding
_publish.ymland repository configuration.
- Code Execution Strategies
- Local execution with freeze vs CI execution.
- Environment management and dependency handling.
- Version control best practices for published projects.
- Advanced Topics
- Custom domains configuration.
- Automated deployment workflows.
- Troubleshooting common publishing issues.
Session Objectives
This session explores comprehensive publishing strategies for Quarto projects, covering multiple deployment platforms, automation workflows, and best practices for different use cases.
Learning Objectives
By the end of this session, participants will be able to:
- Choose the right publishing method for your use case.
- Deploy a Quarto project to multiple platforms.
- Set up automated publishing workflows.
- Troubleshoot common publishing issues.
- Configure custom domains and advanced features.
- Distribute extensions via GitHub or archives.
Quarto Publishing
Publishing Options Overview
| Service | Best For | Key Features |
|---|---|---|
| Quarto Pub | Public content, getting started | Free, simple, 100MB limit |
| GitHub Pages | Open source projects | Git integration, custom domains |
| Netlify | Professional sites | Advanced features, previews |
| Posit Connect | Enterprise/organisations | Security, authentication |
| Other Services | Custom requirements | Firebase, S3, self-hosted |
Start with Quarto Pub for learning, use GitHub Pages for projects, Netlify for production sites
Quarto Pub
Your First Quarto Pub Deployment
- Create an account.
Visit quartopub.com and sign up.
Publish from CLI.
bash
quarto publish quarto-pub
Authenticate.
- Browser opens for authorization
- Confirm publishing permissions
- Site deploys automatically!
Your site is live at https://username.quarto.pub/project-name.
Understanding _publish.yml
Created automatically when you first publish:
_publish.yml
- source: project
quarto-pub:
- id: "abc123-def456-ghi789"
url: "https://myusername.quarto.pub/myproject"- Safe for version control (no credentials).
- Shareable across team members.
- Service configuration stored locally.
- Reusable for subsequent deployments.
Hands-On Exercise: Quarto Pub
Exercise Overview
Objective: Publish the branded project you created in Session 5 using Quarto Pub.
Example Code (reused from Session 5):
bash
tar -xzf "05b-exercises.tar.gz" -C "06-publishing"Publishing to Quarto Pub
- Create a simple Quarto document.
- Add some content (text, code, plots).
- Run
quarto publish quarto-pub. - Share your live URL with a neighbour.
bash
# Publish without prompts
quarto publish quarto-pub --no-prompt
# Publish without opening browser
quarto publish quarto-pub --no-browser
# Publish without re-rendering
quarto publish quarto-pub --no-renderSuccess Criteria
✅ You’ve successfully completed the exercise if you can:
- Successfully publish your Quarto project to Quarto Pub.
GitHub Pages
Three Ways to Use GitHub Pages
Render to docs/
- Simplest approach
- Commit rendered output
- Good for small projects
quarto publish
- Local rendering
- Automatic deployment
- Clean separation
GitHub Actions
- Fully automated
- Triggered by commits
- Most professional
Method 1: Render to docs/
Configure Output Directory
yaml
# _quarto.yml project: type: website output-dir: docs
Add
.nojekyllFilebash
touch .nojekyll
Render and Push
bash
quarto render git add . git commit -m "feat: Add rendered site" git push
Configure Repository
Settings → Pages → Source: Deploy from branch → Branch: main → Folder: /docs
Method 2: quarto publish gh-pages
Setup Source Branch
bash
# Create gh-pages branch git checkout --orphan gh-pages git rm -rf . git commit --allow-empty -m "chore: Initial gh-pages commit" git push origin gh-pages git checkout main
Configure .gitignore
txt
_site/ _book/
Publish
bash
quarto publish gh-pages
Method 3: GitHub Actions Workflow
Create Workflow File:
.github/workflows/publish.yml.yaml
name: Quarto Publish on: workflow_dispatch: push: branches: main 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 }}
Hands-On Exercise: GitHub Pages
Exercise Overview
Objective: Publish the branded project you created in Session 5 using GitHub Pages.
Example Code (reused from Session 5):
bash
tar -xzf "05b-exercises.tar.gz" -C "06-publishing"Publishing to GitHub Pages
Choose one method and deploy your project:
Method 1: docs/ folder
- Modify
_quarto.yml. - Add
.nojekyll. - Render and push.
- Configure in GitHub settings.
Method 2: quarto publish
- Setup gh-pages branch.
- Update
.gitignore. - Run
quarto publish gh-pages. - Verify deployment.
Success Criteria
✅ You’ve successfully completed the exercise if you can:
- Successfully publish your Quarto project to GitHub Pages using one of the methods.
Code Execution Strategies
The Big Decision: Where to Execute Code?
Local Execution + Freeze
_quarto.yml
execute:
freeze: autoPros:
- Faster CI builds.
- Consistent environment.
- Handle legacy code.
Cons:
- Manual re-execution needed.
- Larger repository size.
CI Execution
Pros:
- Always fresh execution.
- Smaller repositories.
- Reproducible environments.
Cons:
- Longer build times.
- Dependency management.
- Potential CI failures.
Freeze Strategy Implementation
Enable Freezing
_quarto.yml
execute: freeze: auto
Re-render Locally
bash
quarto render
Version Control
bash
git add _freeze/ git commit -m "chore: Update frozen computations" git push
The _freeze/ directory stores computational results and must be committed to Git.
CI Execution with Dependencies
yaml
- name: Install Python and Dependencies
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install Jupyter
run: pip install jupyter
- name: Install Requirements
run: pip install -r requirements.txtyaml
- name: Install R
uses: r-lib/actions/setup-r@v2
with:
r-version: '4.5.0'
- name: Install R Dependencies
uses: r-lib/actions/setup-renv@v2
with:
cache-version: 1Version Control Strategies
Use a freeze strategy (recommended):
yaml
execute:
freeze: autoCommit to Git:
- Source files (
.qmd). _freeze/directory.- Configuration files.
Don’t Commit:
_site/,_book/, or_manuscript/.- Temporary files.
- Local dependencies.
Environment Management
Use a tool to manage your R
renvfor R.uv,pip, orcondafor Python.Pkgfor Julia.
Advanced Topics
Custom Domains
Add
CNAMEfile to project root:txt
yourdomain.comConfigure DNS records:
- Apex domain: A records to GitHub IPs.
- Subdomain: CNAME to
username.github.io.
Enable in repository settings.
- Automatic HTTPS.
- Easy DNS management.
- Domain purchasing available.
Extension Distribution
Distribution Methods
GitHub Distribution (Recommended)
bash
# Users install with:
quarto add yourorg/company-report
# Or specific version/tag:
quarto add yourorg/company-report@v1.0.0
# Or from branch:
quarto add yourorg/company-report@mainBenefits: Version control, easy updates, namespace management (yourorg/extension).
Archive Distribution
bash
# From URL:
quarto add https://example.com/company-report.zip
# From local file:
quarto add ./company-report.tar.gzBenefits: No GitHub required, works offline, controlled distribution.
Publishing Best Practices
Prepare your extension:
- Add README.md - Installation instructions and documentation.
- Include LICENSE - Specify usage terms.
- Create example.qmd - Demonstrate usage.
- Version with tags - Use semantic versioning (e.g.,
v1.0.0).
See Distributing Extensions for complete details.