Hosting
On this page we will:
- Enable the GitHub action to automatically render and publish your site.
- Trigger a build and visit your live site.
You can host your Quarto site for free using GitHub Pages. GitHub Pages takes the HTML files that Quarto creates and puts them on the web so that anyone with the link can see your site.
1 Go to Actions tab
Open your fork of the quarto-template repository on GitHub. If you need to find it, go to GitHub → Repositories → quarto-template.
Click on the Actions tab.
2 Enable workflows
GitHub will show a message that workflows aren’t being run on this forked repository.
This is just a safety check. We know what the workflow does (it builds and publishes the Quarto site), so it is safe to enable it for this workshop.
Click the green button to enable Actions for this repository.
After you click, you should see that Actions are now enabled:
3 Set the GitHub Pages branch
Next, tell GitHub Pages which branch to use for the website.
In your repository on GitHub, click on the Settings tab. In the left sidebar, click Pages.
Under Branch, change the source from None to gh-pages. Click Save.
Why
gh-pages?A Git repository can have more than one branch. You can think of branches as different versions or lines of development in the same project.
For this template, the main branch (main) holds your source files (the.qmdfiles,_quarto.yml, etc.), and the workflow puts the built website into a special branch calledgh-pages.
GitHub Pages is then told, “Use the files from thegh-pagesbranch as the live website.””
4 Make a commit to trigger the build
The workflow runs each time you push a commit to GitHub on the main branch. That is how your site will stay up to date.
Go back to your Codespace and make a small change to your site (e.g., edit some text on the homepage), then commit and push you change.
Then, return to your GitHub repository Actions tab, and you should see a new workflow run starting.
Then click on the build-deploy job to watch the steps. Near the end of the “Render and publish to GitHub pages” step, you should see a line with the URL of your site. Click that link (or copy and paste it into your browser).
Then click on the build-deploy job to watch the steps. Near the end, you should see a line with the URL of your site. Click that link (or copy and paste it into your browser).
Sometimes, you may briefly see a 404 error while GitHub finishes publishing. If that happens, wait a few moments and refresh the page.
5 Update the repository “About” url
To make the site easy to find later, add the GitHub Pages URL to the repository’s “About” section.
On the main page of your repository on GitHub, look at the About box on the right, and click the small settings (gear) icon next to it.
Paste your GitHub Pages URL into the Website field then click save changes.
6 How did that work?
The publishing is handled by a GitHub Actions workflow. GitHub Actions is a service that can run steps for you in the cloud when certain events happen (for example, when you push a commit).
The instructions live in a workflow file in .github/workflows/. For this template, it looks like:
1name: Render quarto site and publish on GitHub pages
run-name: Render quarto site and publish on GitHub pages
2on:
push:
branches: main
3jobs:
build-deploy:
4 runs-on: ubuntu-latest
5 permissions:
contents: write
6 steps:
7 - name: Check out repository
uses: actions/checkout@v4
8 - name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
9 - name: Render and publish to GitHub pages
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- 1
- name/run-name: Labels for the workflow and its runs, so you can recognise them in the Actions tab.
- 2
-
on: push: branches: main: Tells GitHub to run this workflow whenever you push a commit to the
mainbranch.
- 3
-
jobs / build-deploy: Defines a job called
build-deploythat does the work.
- 4
-
runs-on: ubuntu-latest: Uses a fresh Linux (Ubuntu) virtual machine in the cloud to run the job.
- 5
-
permissions: contents: write: Allows the job to write back to the repository (needed to update the
gh-pagesbranch). - 6
- steps: The list of actions to perform.
- 7
- Check out repository: Downloads the code from your repository into the runner.
- 8
- Set up Quarto: Installs Quarto so it can render the site.
- 9
-
Render and publish to GitHub Pages: Renders the Quarto project and pushes the built site to the
gh-pagesbranch using thequarto-actions/publishaction.GITHUB_TOKENis a special token that GitHub provides so the workflow can authenticate and push to your repository securely.









