This repository can serve as a template for making training materials using Quarto from:
- Jupyter notebooks aka
.ipynbfiles - R content -
.qmdfiles which mix R (and Python via reticulate, if needed) and md sections - Plain old
.mdfiles
To:
- Support this cross-language functionality
- Keep the repo as lean as possible
- Ensure as little unexpected behaviour as possible, please:
- Do not under any circumstances commit to the main branch without review by someone else;
- Fork the repository, make and test changes, then put in a pull request;
- Please do not add GitHub actions or other "enhacements" that only work for your favourite programming language or workflow, and/or require a lot of extra files to work.
While GitHub actions seem like an amazing enhancement, we often develop materials that use custom libraries, renv or conda environments, docker builds etc.
So if you'd like to use actions:
- Create your custom training workshop repository for your content
- Delete what you don't need from this template
- Create your custom actions script
- Add a note to the bottom of this readme linking to your actions page, so others can use it as an example when creating training using a similar combination of environments and language.
We recommend the following structure for all published content:
- Store
index.qmd,setup.qmdfiles in the root directory - Store notebooks (.ipynb), R files (as .qmd or .rmd), and markdown lessons (.qmd or .md) in the
notebooksfolder - Store figures in a
figsfolder
For all languages/sources:
- Use the big green button "Use this template" this repository
- Edit
index.qmdto change the main landing page. This is basically a markdown file. - Edit or create
setup.qmdto change the Setup instruction pages. Same - basically a md file. - Edit
_quarto.ymlto change the dropdown menu options. - Add additional
*.mdfiles to the root dir to have them converted to html files (and add them to_quarto.ymlto make them navigable), if you'd like. - Edit this Readme in your fork to reflect the content of your workshop.
If you want to use the command line instead of VSCode/RStudio (as described below), run the below commands (after activating the correct Python environment, if needed)
quarto render
# First time you create the file, add them to be tracked by github, e.g.
git add docs/*
git commit -am "your comments"
git pushYou can browse the result locally by exploring the html files created (note: sometimes figures display locally but not on web and the other way around too.)
- You will need to have Jupyter and Quarto installed to convert the notebooks and render them for the web.
- [Recommended, not essential] Use VSCode's Quarto Extension to render the project (recommended b/c it's easier/nice).
- Delete
notebooks/01b-exampleRcontent.qmdand01c-exampleMDcontent.md - Create notebooks in the
notebooksfolder (for examplenotebooks/1_cont.ipynb). Have a look at what the syntax for Challenges, Objectives, Key Points and Questions is supported in01a-fundamentals.ipynb, and use similar syntax across other notebooks where needed. - Execute all the cells in your Jupyter notebook(s) until you're happy with the output/
- Add links to your content to the navigation configuration in
_quarto.yml. For example, to link to the rendered page fornotebooks/1_cont.ipynb, add a link tonotebooks/1_cont.htmlin_quarto.yml
Note:
Building from Jupyter notebooks will not re-render all of the notebooks unless you use the quarto render notebook.ipynb --execute command
.qmdis called "Quarto Markdown", and basically works just like Rmd.- If using R, you will need rmarkdown, xml2 and X to have the notebooks generate properly and link out to the documentation, as specified in the
_quarto.ymlfile. - Building from R will by default re-render all of the outputs.
- Sometimes you have to delete everything in your cache :(
- Delete
notebooks/01a-fundamentals.ipynb,environment.ymland01c-exampleMDcontent.md - Create notebooks in the
notebooksfolder (for examplenotebooks/1_cont.qmd). Have a look at what the syntax for Challenges, Objectives, Key Points and Questions is supported in01b-exampleRcontent.qmd, and use similar syntax across other .qmd files where needed. - Add links to your content to the navigation configuration in
_quarto.yml. For example, to link to the rendered page fornotebooks/1_cont.qmd, add a link tonotebooks/1_cont.htmlin_quarto.yml - Type
quarto renderin the Terminal in RStudio (not the R command line, the Terminal tab!) - or use the buttons.
- Delete
notebooks/01a-fundamentals.ipynb,01b-exampleRcontent.qmdandenvironment.yml - Create files in the
notebooksfolder (for examplenotebooks/1_cont.md). Have a look at what the syntax for Challenges, Objectives, Key Points and Questions is supported in01c-exampleMDcontent.md, and use similar syntax across other .md files where needed. - Add links to your content to the navigation configuration in
_quarto.yml. For example, to link to the rendered page fornotebooks/1_cont.md, add a link tonotebooks/1_cont.htmlin_quarto.yml - Type
quarto renderin the terminal - or use VSCode's "Render Quarto project' command using the command pallette instead.
To publish Quarto websites to GitHub pages, you can:
- Render sites on your local machine (see above)
- Use the
quarto publishcommand - Use GitHub Actions
Enable GitHub pages in your repository settings:
- Go to GitHub repository settings
- Scroll down to "GitHub Pages" section and select the following:
Source: deploy from a branchBranch:mainDirectory: /root
Save
Run the quarto publish command (assuming you are working in terminal)
quarto publishYour Quarto project will be rendered at a URL with this format:
https://pages.github.sydney.edu.au/informatics/<NAME-OF-YOUR-REPO>/Here are some example actions.
Add this action to automatically quarto render && quarto publish. Only works well if your repo uses markdown files exclusively, cannot execute python/R code for example. In the current form, it expects "Github Pages" to be deployed on the gh-pages branch from /(root), i.e. the standard configuration.
# Example from https://github.com/quarto-dev/quarto-actions/blob/main/examples/quarto-publish-example.yml
name: Quarto Publish
on:
push:
branches: main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true
- name: Render Quarto Project
uses: quarto-dev/quarto-actions/render@v2
- name: Publish to GitHub Pages (and render)
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
If you'd like to use a more generic and possibly neutral theme, go to the _quarto.yaml and change the format section to:
format:
html:
toc: true
theme:
light: flatly
dark: darkly
css: styles.scss
code-link: true
code-fold: falseIf you'd like to use the USYD Masterbrand Ochre, go to the _quarto.yaml and change the format section to:
format:
html:
theme: simplex
css: [lesson.css, bootstrap-icons.css]
toc: true
code-overflow: wrap
highlight-style: github