Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Set up your computer

If you’ve never used GitHub, a code editor, or a terminal, start here. None of it is hard, but it’s a lot of unfamiliar words at once, so this page goes slowly and explains each thing the first time it comes up. By the end you’ll have a course open on your own computer, you’ll have changed a sentence in it and seen the change in your browser, and you’ll have an AI assistant sitting next to you for the moments when something doesn’t work.

One thing before you install anything. If all you want is to fix a typo or reword a paragraph, you can skip this page: Change a course does that entirely on a website. Come back here when you want to write new lessons or work on the visuals.

The four things to get

You need a GitHub account and three free programs. Each one does a single job, and it helps to know what that job is.

GitHub is a website that stores the course’s files and keeps every past version of them. It’s also what puts the finished course on the web. Make a free account at github.com.

VS Code is where you’ll do everything else. It’s an editor, like Word, but for plain text files. It shows all the files of a course in a list down the left side, and it’s also what copies a course from GitHub and sends your changes back. Get it at code.visualstudio.com.

Git is the tool VS Code uses behind the scenes to talk to GitHub. You won’t use it directly, but it has to be installed. On Windows, download it from git-scm.com and accept every default in the installer. On a Mac you can skip this: the first time it’s needed, your Mac will offer to install it, and you say yes.

Node is the one you’ll never look at. The engine that turns a course into a website runs on it. Go to nodejs.org, download the version the page offers, and click through the installer.

Get a course onto your computer

The easiest course to start from is Probability 1, because it already has one of everything. On GitHub, go to canonlearning/probability-1 and press Fork near the top right. A fork is your own copy. It lives under your account, and nothing you do to it can damage the original.

Now bring your copy down to your computer. Open VS Code, and on its welcome screen choose Clone Git Repository. Then choose Clone from GitHub. The first time, VS Code opens your browser and asks you to sign in to GitHub, and after that it lists your repositories. Pick probability-1, and pick a folder to keep it in. Documents is a good choice. “Clone” just means “download a copy that stays connected to GitHub”.

When it finishes, VS Code asks whether to open the course. Say yes, and say yes again if it asks whether you trust the folder. You should see the course’s folders down the left: lessons, problems, lectures, visuals. Click lessons, then conditional-probability.md, and you’re looking at a lesson.

What you’re looking at

That file is written in Markdown, which is the format every lesson, problem, and slide deck uses. Markdown is ordinary text with a few marks that say how it should look. You already know most of it from reading it:

# A title

## A section heading

A paragraph is just a paragraph. Leave a blank line between paragraphs.
Put **two stars** around words to make them bold.

- a dash starts a bullet
- and another

> A line starting with > is a callout.

The one part that will be new unless you’ve used LaTeX is the math. Math goes between dollar signs, so $\frac{1}{2}$ shows up as a fraction one half. You don’t have to memorize any of it. Copy what the existing lessons do, and ask the assistant (below) for anything you can’t find.

See it in your browser

A lesson file isn’t the web page yet. The engine builds the page, and you start the engine by typing two short commands.

In VS Code, open the Terminal menu at the top and choose New Terminal. A panel opens at the bottom with a blinking cursor. Type this and press Enter:

npm install

It downloads the engine, which takes a minute and prints a lot of text you can ignore. You only do this once. Then type:

npm run dev

It prints an address, http://localhost:4000. Open that in your browser and there’s the course, running on your own computer. Nobody else can see it yet.

Now try the thing this was all for. Go back to VS Code, change a sentence in the lesson, and save with Ctrl+S (Cmd+S on a Mac). Look at the browser. The page has already updated. That’s the whole loop for writing a course: type, save, look.

When you’re finished for the day, click in the terminal panel and press Ctrl+C to stop it. Next time, you only need npm run dev.

Add an AI assistant

You can paste an error or a lesson into Claude, ChatGPT, or Gemini in your browser and get good help. It’s better to use one that works inside VS Code, because it can read the whole course and make the change itself. All three have one: Claude Code, Codex from OpenAI, and Gemini Code Assist. Search for the name in the Extensions panel on the left, install it, and sign in with the account you already have. Copilot, which comes with VS Code, does the same job.

It’s useful for the terminal errors, for math that won’t display, for drafting problems in the style of the ones already there, and above all for the visuals, which are code.

Save your work and publish it

Your changes are only on your computer so far. Sending them to GitHub takes two steps, and both are buttons in VS Code.

There is one bit of setup first, which you do once. Git wants to know whose name to put on your changes. In the terminal panel, type these two lines with your own name and the email you used for GitHub, pressing Enter after each:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Now click the Source Control icon in the strip down the far left. It looks like a branching line, and it has a number on it when you’ve changed something. The panel lists the files you changed. Type a few words in the box at the top about what you did (“Reworded the opening of lesson 1”) and press Commit. If VS Code asks whether to include all your changes, say yes. Then press Sync Changes. Commit means “save this as a version”, and sync means “send it to GitHub”.

To put your course on the web, there’s a one-time switch. On your fork’s page on GitHub, open Settings, choose Pages on the left, and set Source to GitHub Actions. Then open the Actions tab and turn workflows on. From then on, every time you sync, your site rebuilds, and a minute or two later it’s live at https://<your-name>.github.io/probability-1/.

That’s everything. From here, Make a course explains what goes in each kind of file, one at a time.

Make a course

A Canon Learning course is just a folder of text files. The lessons, the practice problems, and the slides are Markdown, and each interactive visual is one TypeScript file. A program called the engine reads that folder and turns it into a website.

The easiest way to see how it fits together is to build a tiny course from nothing, so that’s what this page does. The course has a single lesson about flipping a coin twice. You’ll get the lesson on screen first, then give it a practice problem, a visual, and a set of slides, and finish by putting it on the web.

The only thing you need installed is Node, version 24 or newer. If a terminal is new to you, read Set up your computer first. Start with an empty folder:

mkdir coin-course
cd coin-course
mkdir lessons

A course needs three files before the engine can build it. The first one tells your computer where to get the engine and gives you two commands, dev and build. You won’t need to touch it again.

package.json

{
  "private": true,
  "scripts": {
    "dev": "canon dev",
    "build": "canon build"
  },
  "dependencies": {
    "canon": "github:canonlearning/canon"
  }
}

The second file is the table of contents. It gives the course a title and lists the lessons in the order they should be read. Each lesson’s id is its file name without the .md, and the summary is the one sentence that shows up beside its title on the home page.

course.yaml

title: Coin Course
description: A course with one lesson.

lessons:
  - id: two-flips
    summary: the four outcomes of flipping a coin twice.

The third file is the lesson, and it’s ordinary Markdown. The first line is the title, a ## line starts a section, and math goes between dollar signs the way it does in LaTeX. The line starting with > at the end is a callout: the bold words become its label, and it’s how a lesson asks the reader to stop and do something on paper.

lessons/two-flips.md

# Two flips

A fair coin is flipped twice. Each flip is heads or tails, so there are
$2 \times 2 = 4$ outcomes, and each one is equally likely.

## Count the outcomes

Exactly one of the 4 outcomes has two heads, so

$$P(\text{two heads}) = \frac{1}{4}.$$

> **On paper** Write out all 4 outcomes.

That’s a complete course. Download the engine and start it:

npm install
npm run dev

Open http://localhost:4000 and the course is there, with the math typeset. Leave it running. Every time you save a file the page reloads, so you can write with the browser open next to your editor.

Add to it

Right now the lesson explains an idea and then gives the reader nothing to try it on. That’s what practice problems are for. A problem is its own file, in a folder called problems, and its worked solution lives in the same file. The block at the top holds the title and the answer. Everything above ## Solution is the question, and each ### line under it names one step of the solution.

problems/at-least-one-head.md

---
title: At least one head
answer: $3/4$
---

A fair coin is flipped twice. What is the probability of at least one head?

## Solution

### Count the outcomes with no head

Only one of the 4 outcomes, two tails, has no head.

### Subtract from the total

The other 3 outcomes have at least one head, so the probability is

$$\frac{3}{4}.$$

Write the answer exact, as 3/4 and not 0.75, because someone checking their work by hand can’t match it against a rounded number.

A problem only shows up once a lesson claims it, so add two lines to course.yaml:

course.yaml

lessons:
  - id: two-flips
    summary: the four outcomes of flipping a coin twice.
    problems:
      - at-least-one-head

Save, and the lesson now ends with the problem. The solution stays folded shut until the reader opens it. Nothing is hidden for teachers only: every solution in a Canon course is public.

So far this is a page of text and formulas, and that isn’t really the point of Canon. A lesson is supposed to be built around something the reader can watch and play with, with the text filling in only what the picture can’t say. Those are the visuals. Each one is a TypeScript file in a folder called visuals, holding a class with a build method that draws into the figure it’s handed. Here is about the smallest one that draws anything: a red ball on a floor, with a label, a readout underneath, and a caption.

visuals/one-ball.ts

import { ball, floor, palette, Stage, Visual, type Figure } from "canon";

export default class OneBall extends Visual {
  protected build(figure: Figure): void {
    const stage = new Stage(figure, { halfWidth: 4 });

    const redBall = ball(palette.red, 0.4);
    redBall.position.copy(floor(0, 0, 0.4));
    stage.scene.add(redBall);

    stage.label("a ball").position.copy(floor(0, 0, 0.9));
    figure.readout("<b>1</b> ball");
    figure.caption("One red ball on the floor.");
  }
}

Everything it uses comes from "canon": the Stage is a 3D scene, ball is one of a handful of ready-made shapes, and palette is the four colors all the visuals share. To put it in the lesson, add one line wherever you want it to appear, naming the file without the .ts:

lessons/two-flips.md

::visual{name="one-ball"}

You can drag it to turn the view, which is about all this one does. A real visual steps through a count or has a slider that changes a probability, and the quickest way to learn how is to read the ones in Probability 1 and copy from them.

The last piece is for teaching the lesson to a room. A slide deck is one more Markdown file, in a folder called lectures, written the same way as a lesson. A line of --- starts a new slide, and a callout labeled **Notes** holds what you plan to say, which the room never sees.

lectures/two-flips.md

# Two flips

> **Notes** Ask the room to guess before showing the next slide.

---

## How many outcomes?

- The first flip has 2 results
- The second flip has 2 results
- Together: 4 outcomes

---

## Which is most likely?

1. Two heads
2. Two tails
3. One of each
4. All three are equally likely

You don’t lay slides out. What you write on one decides how it looks: the bulleted list appears one point per key press, and the numbered list turns into choices A to D for the room to vote on. Like a problem, the deck gets listed under its lesson:

course.yaml

lessons:
  - id: two-flips
    summary: the four outcomes of flipping a coin twice.
    problems:
      - at-least-one-head
    lectures:
      - two-flips

The lesson page now links to its slides. The arrow keys move through them, N shows your notes, and F fills the screen.

Put it on the web

Everything so far lives on your computer. To get a real website out of it, run the other command:

npm run build

That writes the finished site into a folder called dist. It’s plain files that don’t care where they live, so you can upload the folder to any web host and it will work.

If you’d rather not upload anything by hand, GitHub will build and host the course for free. Put the course in a GitHub repository and add this one file, which tells GitHub to rebuild the site whenever you push a change.

.github/workflows/publish.yml

name: Publish

on:
  push:
    branches: [main]

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  publish:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
      - run: npm install
      - run: npm run build
      - uses: actions/upload-pages-artifact@v5
        with:
          path: dist
      - uses: actions/deploy-pages@v5

Then open the repository’s Settings, go to Pages, and set the source to “GitHub Actions”. After your next push the course is live at https://<your-name>.github.io/coin-course/, and it updates itself every time you push after that.

Change a course

You don’t have to write a course from scratch to have your own. Every Canon Learning course can be copied and changed, so if you want a different example in a lesson, a shorter reading, or your own practice problems, you take a copy and edit it. You can do all of it on github.com without installing anything.

Say you want to change a sentence in Probability 1. Go to its repository and press Fork. That gives you a full copy under your own account, and nothing you do to it touches the original.

A fresh fork isn’t published yet, because GitHub leaves that switched off until you ask. In your fork, open Settings, go to Pages, and set the source to “GitHub Actions”. Then open the Actions tab and turn workflows on. You only do this once.

Now make the change. Each lesson is one Markdown file in the lessons folder, so open lessons/conditional-probability.md, press the pencil, edit the sentence, and commit. The commit kicks off a build, and a minute or two later your version of the course is live at https://<your-name>.github.io/probability-1/.

Problems and slides work the same way. Problems are in problems, slide decks are in lectures, and Make a course walks through what goes in each kind of file.

As for what you’re allowed to do with it: the content is licensed CC BY 4.0, which means you can change it and publish it, including for a class that charges tuition, as long as you say where it came from. The exact terms are in the course’s LICENSE.md.

Contribute

These courses will get better faster if more than one person writes and checks them. If you spot a mistake, or have a good problem, a visual, or a whole lesson to add, you can send it back to the course it belongs to.

For something small, like a typo or a wrong number, you don’t need to set anything up. Every lesson page has a “Page source” link under its title that opens the Markdown file on GitHub. Press the pencil there, make the fix, and GitHub will offer to propose it to the course.

For something bigger, it’s worth a quick conversation before you put the work in. Open an issue on the course’s repository saying what you have in mind. Once that’s agreed, fork the course, make the change, and open a pull request. Make a course shows how to preview the course on your own computer while you write.

A few things decide whether a contribution gets merged, and they’re the same things the existing lessons are held to. A person has to have checked it by hand: every problem and its solution gets worked on paper before it goes in, no matter who or what wrote the first draft. A lesson has to be built around its visuals, with the text saying only what a visual can’t, so a page of prose with one figure dropped in will come back. It has to stay plain Markdown that a teacher could open and edit without learning a framework. And answers are exact: a fraction, not a rounded decimal.

Probability 1 is only the first course, and nothing in the engine is tied to probability. If you’d like to start a course in another subject, open an issue on the engine’s repository and describe it.