The tooling behind Neuromatch courses built with MyST, in one versioned package:
- MyST plugin:
{nma-video},{nma-slides},{nma-solution},{nma-explanation},{nma-instructor}(notes for the instructor site),{nma-feedback},{nma-data}(data files the code reads), scrollytelling pages ({step},{stage}) and editable, runnable code cells. nma-kitCLI: content checks, notebook generation (student, instructor, solutions), scrolly pre-rendering, site preparation, notebook publishing.- Site branding: the Neuromatch stylesheet, Rubik font, logos and favicon,
written into a course by
nma-kit sync-assets. - Reusable GitHub workflows: check pull requests, preview them on Cloudflare Pages, publish notebooks and the site to GitHub Pages, and optionally publish an instructor site.
Courses use a version of the kit instead of carrying a copy, so a fix ships once. Start a course from neuromatch/course-template, which teaches the authoring conventions.
The quickest start is nma-kit init, which writes a working course (config,
workflow, an example day, a README with the setup checklist):
uvx --from neuromatch-course-kit nma-kit init my-coursePass --title, --author, --github, --license to skip the questions, and
--preview to enable pull request previews. The steps below are what it sets
up, for adding the kit to an existing course.
-
In
myst.yml, extend the kit's config (it adds the plugin and turns on JupyterLite):version: 1 extend: https://cdn.jsdelivr.net/npm/@neuromatch/course-kit@0.4/dist/nma.yml project: github: https://github.com/<org>/<course> # ... site: template: book-theme options: folders: true logo_text: My Course Title # your course's name next to the logo # The kit's branding, written to _nma/ by `nma-kit sync-assets`: style: _nma/site.css logo: _nma/logo.svg logo_dark: _nma/logo-dark.svg favicon: _nma/favicon.png
-
Copy
templates/course.ymlto.github/workflows/course.yml. Pull requests are checked and previewed (see Pull request previews); pushes tomainpublish the notebooks (tonotebooks-branch, created automatically) and the site. -
In the repo's Settings → Pages, set Source to GitHub Actions (and the custom domain, if any; no
CNAMEfile needed). -
Generate the branding files once for local previews (CI does it for you):
uv run nma-kit sync-assets
This writes
_nma/(stylesheet, logos, favicon). The folder ignores itself, so nothing gets committed. Re-run it after upgrading the kit. See Site branding. -
List the packages your tutorials import in
requirements.txt(CI installs them next to the kit;nma-kit render-scrollyexecutes scrolly pages).
Settings, in the nma: block of myst.yml. content is required (there are no
defaults); the rest are optional (defaults shown, except brand and style, which are unset):
nma:
content: # content roots: the folders that hold your pages
- tutorials # a folder inside the course; its notebooks go to notebooks/tutorials/
- {name: guide, path: docs/guide} # name is optional (default: the path); notebooks go to notebooks/guide/
notebooks:
branch: notebooks-branch # where generated notebooks are published
# (the NMA_NOTEBOOKS_BRANCH env var overrides it; PR previews use it)
feedback: # needed if any page uses {nma-feedback}
url: https://...
project: ...
user_key: ...
scrolly:
pyodide_url: https://cdn.jsdelivr.net/pyodide/v314.0.7/full/
assets: # folders (inside a day folder) for {nma-data} files and {nma-slides} PDFs
data: data
image: images
slides: slides
brand: # colours, see "Site branding"
primary: "#008CBF"
style:
extra: _static/extra.css # your own CSS, appended after the kit'snma.content lists the folders whose pages the kit processes. Name them whatever
fits your course (tutorials, labs, docs/guide); the kit gives them no meaning.
- Every
.mdpage in a root belongs to it. A page with akernelspecin its frontmatter also gets a notebook, badges and solution files. Any other page is a plain site page, and its directives ({nma-video},{nma-slides}, ...) still work. - The name is the first folder under
notebooks/(and_build/scrolly/). It defaults to the path. Keep a name when you move a folder and want published notebook URLs to stay. - Folders are relative and inside the course: no
.,..or absolute paths, nothing undernotebooks/,_build/,_nma/ornode_modules/. Roots cannot nest, and names are unique.nma-kit checkreports every violation. - Upgrading from 0.3: replace
nma.paths.tutorials/nma.paths.projectswithcontent: [tutorials, projects](addname: tutorialsto a renamed folder to keep its URLs).
Reviewers read markdown diffs, so they never see scrolly pages, editable cells
or the Colab buttons. The preview job in the template builds each pull
request and deploys it to Cloudflare Pages at
a public URL, https://pr-<number>.<project>.pages.dev, which updates on every
push. One comment on the pull request carries the link.
- Notebook buttons open the PR's notebooks. The preview pushes them to the
branch
notebooks-pr-<number>and setsNMA_NOTEBOOKS_BRANCH, which every Colab, Kaggle, solution and data-download link follows. The productionnotebooks-branchand the Pages site are never touched. The branch is public like the repo (Colab and Kaggle read raw GitHub URLs, so the repo must be public). - Cleanup. Closing the pull request deletes the branch and the Cloudflare deployments and marks the comment as removed.
- Same-repository pull requests only. Pull requests from forks get no secrets, so they get no preview (the check still runs).
Setup, once per course repository:
- In Cloudflare, create an API token (My Profile → API Tokens → Custom token) with Account → Cloudflare Pages → Edit, and note the account ID (Workers & Pages overview).
- In the repo (Settings → Secrets and variables → Actions), add the secrets
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_ID, and the variableCLOUDFLARE_PROJECT(the Pages project name; the first preview creates it). - Use the
previewjob fromtemplates/course.yml(and itspull_requesttypes, which includeclosed). The job needscontents: writeandpull-requests: write.
Without the secrets the job still builds the site and skips the deploy with a notice, so a course can adopt the template before it has Cloudflare. Delete the job to turn previews off.
When the instructor site is on (the variable
CLOUDFLARE_INSTRUCTOR_PROJECT is set), each push is built a second time as the
instructor site, and the comment carries a second link,
https://pr-<number>.<instructor project>.pages.dev. It goes to the instructor
project as the branch pr-<number>, never to the project's production branch
(the live instructor site), with the same secrets. Closing the pull request
removes both previews. Without the variable there is no second build.
A second build of the same course for instructors, published at its own address
such as instructor.<course domain>. It differs from the student site in four
ways:
{nma-solution}and{nma-explanation}show their content inline, in collapsed boxes, instead of "Click for solution" links.- The Colab and Kaggle buttons open the generated instructor notebooks (solutions filled in).
{nma-instructor}notes (teaching notes: timing, common mistakes) appear as "Instructor notes" boxes. They are removed from the student site and from every generated notebook.- Search engines are told to stay away (
robots.txtand anoindexheader), and there is no sitemap.
It is not access controlled: the solutions stay on the public notebooks
branch, and students may read them. It is a convenience view, built by setting
NMA_AUDIENCE=instructor.
{nma-instructor} takes Markdown and sits at the top level of a page:
:::{nma-instructor}
Allow 10 minutes here. Students often forget the sign.
:::Setup, once per course repository (the course template's publish job already
passes the settings):
- Optional: in Cloudflare, create a Pages project (Workers & Pages → Create →
Pages → Direct Upload), for example
my-course-instructor. The first deploy creates it otherwise. - In the repo (Settings → Secrets and variables → Actions), set the variable
CLOUDFLARE_INSTRUCTOR_PROJECTto the project name. The secretsCLOUDFLARE_API_TOKEN(Cloudflare Pages: Edit) andCLOUDFLARE_ACCOUNT_IDare the ones the pull request previews use. - Make sure the
publishjob in.github/workflows/course.ymlhas theinstructor-cloudflare-projectinput andsecrets: inherit(seetemplates/course.yml). - Push to
main, so the project gets its first deployment. - In the Cloudflare project: Custom domains → Set up a custom domain →
instructor.<course domain>. If the domain's DNS is on Cloudflare, accept the CNAME it offers. Otherwise add a CNAME frominstructorto<project>.pages.devat your DNS provider. The kit does not manage DNS. - Check: open the address, a solution shows inline, and
/robots.txtsaysDisallow: /.
Without the variable or the secrets the job is skipped and nothing else changes. To build it locally, export the audience so every command sees it:
export NMA_AUDIENCE=instructor
nma-kit prepare-site && myst build --html && nma-kit finalize-site
git checkout -- tutorials projects myst.yml # undo prepare-sitecourse-nightly.yml runs every generated instructor notebook (solutions filled in, so no
intentional errors) in Google's Colab runtime image and reports what broke. It is optional: copy
templates/nightly.yml to .github/workflows/nightly.yml in the course
(new and existing courses alike; nma-kit init does not add it). It runs the browser notebooks every
night and the runtime: colab ones every Sunday, and can be started by hand from the Actions tab.
Scheduled workflows only run from the default branch. The Colab image is large, so the notebooks are
dealt out to at most shards jobs (default 4); each job pulls the image once and runs its share in turn.
The call looks like this:
jobs:
notebooks:
uses: neuromatch/course-kit/.github/workflows/course-nightly.yml@v0.4
with:
runtime: browser # or colab; empty runs them all
permissions:
contents: read
issues: writeIt runs on CPU. A page with runtime: colab (GPU or ML-library notebooks) that fails or times out is
listed as needs-check, to be confirmed by hand in Colab with a GPU, and does not turn the run red;
any other notebook that fails or times out does. Failures go to the job summary and to one GitHub issue
(label course-nightly) that is updated on each run and closed when everything passes. Locally:
nma-kit notebooks && nma-kit run-notebooks.
The kit carries the Neuromatch look: the colour palette, the Rubik font (embedded in the stylesheet, so the kit's own CSS makes no font requests), the logos and the favicon. It also styles the kit's own widgets (editable cells, scrollytelling) and hides JupyterLite's toolbar, so courses no longer carry that rule themselves.
nma-kit sync-assets writes these files to _nma/ in the course:
| File | Used as |
|---|---|
_nma/site.css |
site.options.style: the kit stylesheet, then your colour overrides, then your own CSS |
_nma/logo.svg, _nma/logo-dark.svg |
site.options.logo, logo_dark |
_nma/favicon.png |
site.options.favicon |
CI runs it as part of nma-kit prepare-site. Locally, run it once and again
after upgrading the kit. MyST accepts a single style file, which is why the
kit stylesheet and your own CSS are combined into _nma/site.css.
Change the colours with the nma.brand block (all keys optional, each a
"#RRGGBB" string):
nma:
brand:
primary: "#D9480F" # links, accents, buttons
primary_hover: "#A63700" # default: primary, 25% darker
primary_light: "#FF8A57" # accent on dark backgrounds, default: primary, 35% lighter
secondary: "#45429C" # header surface, tips
accent: "#FA7A7A" # exercise cellsAdd your own CSS with nma.style.extra: the file (relative to the course
root) is appended after the kit's CSS, so its rules win. The brand colours are
CSS variables (--nma-brand-primary, ...), so your CSS can use them too.
nma-kit check reports unknown keys and malformed colours. The course title
and logo_text stay in your myst.yml.
The kit is on 0.x until it is stable. A breaking change bumps the minor
version (0.1 → 0.2); features and fixes bump the patch (0.1.0 → 0.1.1). So a
v0.MINOR line only gets compatible changes.
The ref in your workflow file is the only knob. Each release of the
reusable workflows installs that exact CLI version, and nma-kit prepare-site
rewrites the extend: URL in myst.yml to the same exact version before the
build, so the plugin, its assets and the CLI always come from one release.
| You want | Workflow ref | What happens |
|---|---|---|
| Live, safe updates (recommended) | @v0.4 |
Every build uses the newest 0.4.x |
| Live updates including breaking changes | @v0 |
Newest 0.x, whatever it is |
| Bleeding edge | @main |
The kit's main branch |
| A frozen course | @v0.4.0 or a commit SHA |
Never changes (Dependabot can propose bumps) |
From 1.0 on, the safe live ref is @v1.
About "latest": GitHub Actions has no automatic latest ref; the floating
tags above are "latest within a line". jsDelivr does serve @latest, but it
caches alias URLs (@0.4, @latest) for up to 7 days and @latest crosses
major versions, so don't put @latest in myst.yml. The alias you commit
there only matters for local previews (CI pins it). To force the newest
release on CI, pass kit-version: latest to the workflow.
Local previews cache the downloaded plugin for 30 days in _build/cache;
myst clean --cache refreshes it.
uv venv && uv pip install -r requirements.txt neuromatch-course-kit==0.4.*
uv run nma-kit check
uv run nma-kit sync-assets # site branding, written to _nma/
uv run nma-kit render-scrolly # optional: real outputs on scrolly pages
uv run myst startBug reports and pull requests are welcome. CONTRIBUTING.md covers setup, tests, the Python/JS "twin" rule and how to add a feature; AGENTS.md describes how each feature is built. Maintainers: see docs/releasing.md.
BSD-3-Clause.