Publishing
Session 6
Session Overview
Session 6: Publishing
- Publishing Options Overview
- Comparison of Posit Connect Cloud, GitHub Pages, Netlify, and other hosting services.
- Understanding benefits and limitations of each platform.
- Choosing the right publishing method for different use cases.
- Posit Connect Cloud and GitHub Pages
- Step-by-step Posit Connect Cloud 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 & Extension Distribution
- Custom domains configuration.
- Extension distribution via GitHub and archives.
- Publishing best practices for extensions.
Session Objectives
This session explores comprehensive publishing strategies for Quarto projects, covering Posit Connect Cloud, GitHub Pages, 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 |
|---|---|---|
| Posit Connect Cloud | Public content, getting started | Free tier, simple, Posit account |
| 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 Posit Connect Cloud for learning and public content, use GitHub Pages for open source projects, and Netlify or Posit Connect for production sites.
Posit Connect Cloud
Your First Posit Connect Cloud Deployment
- Create an account. Visit connect.posit.cloud and sign up for a Posit account.
Publish from CLI.
bash
quarto publish posit-connect-cloud
Authenticate.
- Browser opens for authorisation.
- Confirm publishing permissions.
- Site deploys automatically.
Your site is live on Posit Connect Cloud.
Understanding _publish.yml
Created automatically when you first publish:
_publish.yml
- source: project
posit-connect-cloud:
- id: "5f3abafe-68f9-4c1d-835b-9d668b892001"
url: "https://connect.posit.cloud/content/5f3abafe-68f9-4c1d-835b-9d668b892001"- Safe for version control (no credentials).
- Shareable across team members.
- Service configuration stored locally.
- Reusable for subsequent deployments.
See Posit Connect Cloud for complete documentation.
Hands-On Exercise: Posit Connect Cloud
Exercise Overview
Objective: Publish the branded website project from Session 5 using Posit Connect Cloud.
Example Code (reused from Session 5):
bash
tar -xzf "05a-exercises.tar.gz" -C "06-publishing"Publishing to Posit Connect Cloud
- Extract the branded website project.
- Preview locally with
quarto preview. - Run
quarto publish posit-connect-cloud. - Share your live URL with a neighbour.
bash
# Publish without prompts
quarto publish posit-connect-cloud --no-prompt
# Publish without opening browser
quarto publish posit-connect-cloud --no-browser
# Publish without re-rendering
quarto publish posit-connect-cloud --no-renderSuccess Criteria
✅ You’ve successfully completed the exercise if you can:
- Successfully publish your Quarto project to Posit Connect Cloud.
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@v6 - 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 website project from Session 5 using GitHub Pages.
Example Code (reused from Session 5):
bash
tar -xzf "05a-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.