Tutorial 9
Creating a quarto website.
You can see the course notes for quarto + github pages here: https://ubc-dsci.github.io/reproducible-and-trustworthy-workflows-for-data-science/lectures/930-quarto-ghpages.html
You will be doing the final exercise listed in the chapter for the tutorial.
*Creating and Deploying a Quarto Website**
Objective: By completing this exercise, students will gain hands-on experience in creating a Quarto website and deploying it using GitHub Pages.
Instructions:
Create a New Quarto Website Project:
- Open your command line interface (Terminal on Mac/Linux, Command Prompt/PowerShell on Windows).
 - Use the 
quarto create projectcommand to create a new Quarto website project. 
quarto create project- Select “website” as the project type and provide a directory name for your project.
 
Navigate to Your Project Directory:
- Change into the newly created project directory.
 
cd your_project_directoryCustomize Your Quarto Website:
- Open the 
_quarto.ymlfile in a text editor and customize the settings as needed. 
project: type: website output-dir: docs- Modify the content of the 
index.qmdandabout.qmdfiles to personalize your website. 
- Open the 
 Render Your Quarto Website:
- Use the 
quarto rendercommand to generate the HTML files for your website. 
quarto render- Verify that the output is created in the 
docsdirectory. 
- Use the 
 Initialize a Git Repository:
- If you haven’t already, initialize a Git repository in your project directory.
 
git init- Add all files to the Git repository and commit them.
 
git add . git commit -m "Initial commit of Quarto website"Push Your Project to GitHub:
- Create a new repository on GitHub and follow the instructions to push your local repository to GitHub.
 
git remote add origin https://github.com/YOUR_GITHUB_USERNAME/YOUR_REPOSITORY_NAME.git git branch -M main git push -u origin mainEnable GitHub Pages:
- Go to the settings of your GitHub repository.
 - Under the “Pages” section, set the source to the 
docsfolder on themainbranch. - Save the settings and wait for GitHub to publish your website.
 
Verify Your Website:
- Navigate to 
https://YOUR_GITHUB_USERNAME.github.io/YOUR_REPOSITORY_NAMEto see your published Quarto website. 
- Navigate to 
 Migrate the website to the gh-pages branch
- delete the 
docsfolder that renders your website - ignore the 
docsand_sitefolder in your.gitignore - Create and publish your website to the 
gh-pagesbranch 
git checkout --orphan gh-pages git reset --hard # make sure all changes are committed before running this! git commit --allow-empty -m "Initialising gh-pages branch" git push origin gh-pages quarto publish gh-pagesYou can still use regular
quarto renderorquarto previewto build your site locally, you will no longer need to manually build and push the site to themainbranch- delete the 
 Auto build the site using a github action
- Auto build the website when changes are pushed to main. make sure you manually publish to the gh-pages branch before creating the workflow.
 
on: workflow_dispatch: push: branches: main name: Quarto Publish 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 }}