Publishing

Publishing your site

Hamel Husain

Parlance Labs

Background

  • Render your site quarto render
    • This put static files in _site/ by default, but can change it with the output-dir setting:
_quarto.yml
project:
  type: website
  output-dir: _site
  • The _site/ folder is a static site you can deploy anywhere. Ex: python -m http.server --d _site/
  • Preview your site quarto preview

Intro

Easiest way to get started:

quarto publish --help

Built in targets:

  • Quarto Pub (quarto-pub)
  • GitHub Pages (gh-pages)
  • Posit Connect (connect)
  • Netlify (netlify)
  • Confluence (confluence)

GitHub Pages

  • It’s free
  • Cannot get private pages without paying.
quarto publish

Enable GitHub Pages

Make sure you enable GitHub Pages in your repo settings.

GitHub Actions

See this repo, specifically this example:

name: pub
on:
    push:
        branches: main
jobs:
    pub:
        permissions:
            contents: write
            pages: write
        runs-on: ubuntu-latest
        steps:
        - name: Check out repository
          uses: actions/checkout@v4
        - name: setup Python
          uses: actions/setup-python@v3
        - name: install Jupyter
          run: python3 -m pip install jupyter
        - name: Install Quarto
          uses: quarto-dev/quarto-actions/setup@v2
        - name: Publish to GitHub Pages (and render)
          uses: quarto-dev/quarto-actions/publish@v2
          with:
            target: gh-pages

See my code. Remember: Enable GitHub Pages in your repo settings.

What I do

  • I am an expert at GitHub Actions, but I still prefer to use quarto publish.
  • I’ve found that iterating on GitHub Actions can waste a lot of time.
  • For larger projects with multiple collaborators, I would use the GitHub Actions approach.

Have some fun

You can render or preview single files with quarto render or quarto preview.

hamelsmu/quarto-render.

Example:

http://127.0.0.1:8000/render/https://github.com/huggingface/notebooks/blob/main/examples/tokenizer_training.ipynb

Exercise

  1. Create a new GitHub repo
  2. Publish your site with the CLI to GitHub Pages
  3. Setup GitHub Actions to publish your site to GitHub Pages for you