Skip to content

This website

← Back to the start

The primer is a folder of plain Markdown pages, and the same pages build this website. You can read them on GitHub, print them, or publish your own copy as a website. On DigitalOcean's App Platform that's free for a small site like this, and it takes about half an hour the first time.

  1. How it's built
  2. Trying it on your own computer
  3. Publishing it on DigitalOcean
  4. Keeping it up to date
  5. Its own address
  6. Who can find it
  7. What it costs
  8. When something doesn't work

How it's built

Zensical, a free program from the team that made Material for MkDocs, turns a folder of Markdown pages into a website, with the look, the search box and the dark mode built in. It reads its settings from mkdocs.yml, the file MkDocs uses, so the settings didn't have to be rewritten. The pages themselves don't change: the links between them work on GitHub and on the website alike, and README.md becomes the home page.

A handful of files do the rest:

File What it does
mkdocs.yml The site's settings: its name, its look, and the menu down the side
requirements.txt The exact versions of the programs that build it
overrides/main.html Two small additions to every page: the line that asks search engines not to list it, and a Copy button on each prompt
.gitignore Keeps the built site, the build's cache and the setup for previewing it out of Git
.do/app.yaml DigitalOcean's settings, for the command-line route below

A few choices worth knowing about:

  • No tracking. There's no visitor counting, no cookie banner and no fonts loaded from another company's servers. The site uses the reader's own fonts.
  • No link back to the repo. Nothing on the site points to where its pages are kept, so the repo can stay private.
  • Kept out of search engines until you change one line. See Who can find it.
  • A strict build. A broken link between pages, or a link to a heading that doesn't exist, stops the build, so the site never goes up half-broken. A page left out of the menu doesn't stop it: the page is built but has no place in the menu, so look for it there after you add one.

Zensical is young, so requirements.txt pins one exact version. Moving to a newer one is a one-line change you can try on your own computer first.

Trying it on your own computer

You'll need Python 3.11 or later. From the folder that holds the pages:

python3 -m venv .venv               # a private Python setup for this folder
source .venv/bin/activate           # on Windows: .venv\Scripts\activate
pip install -r requirements.txt
zensical serve                      # preview at http://localhost:8000

The preview updates as you edit a page. Press Ctrl+C to stop it. To build the finished site and check every link, the same way DigitalOcean will:

zensical build --strict             # the website ends up in site/

Publishing it on DigitalOcean

App Platform builds the site from a GitHub repo and hosts it, and it rebuilds the site by itself whenever the pages change. You'll need a DigitalOcean account.

First, decide where the pages live

In a repo of their own (what we'd suggest). The settings are simplest, and you can make that repo public without sharing anything else. If you're copying the pages out of a bigger repo whose history holds older drafts, start the new repo fresh rather than copying that history. Make an empty repo on GitHub, then:

git clone https://github.com/<your-account>/<old-repo>.git old-copy
mkdir primer-site
cp -R old-copy/ai-primer/. primer-site/     # the /. copies the hidden files too
cd primer-site
git init -b main
git add -A
git commit -m "The primer website"
git remote add origin https://github.com/<your-account>/<new-repo>.git
git push -u origin main

Look over the new repo on GitHub before you make it public, since everything in it will be readable by anyone.

As a folder inside a bigger repo. That works too: you tell DigitalOcean which folder to build. The repo can stay private, because DigitalOcean only needs permission to read it, and only the built pages are published, not the repo or its history.

In the control panel

  1. Sign in to DigitalOcean and choose Create, then App Platform.
  2. Choose GitHub as the source. The first time, DigitalOcean asks to install its GitHub app. Give it only the repo that holds the pages.
  3. Pick the repo and the main branch. If the pages are in a folder, set the source directory to that folder, such as /ai-primer. Leave autodeploy on, so each change to main updates the site.
  4. DigitalOcean sees requirements.txt and may guess that this is a Python web service. Edit the component and change its type to Static Site. This one matters: a web service is billed every month, and a static site of this size isn't.
  5. Set the build command to zensical build --strict and the output directory to site.
  6. Check that the summary shows a static site at $0.00 a month, give the app a name, and create it.

The first build takes a few minutes. When it finishes, the app's page shows the site's address, which ends in .ondigitalocean.app. Open it and click around before you share it.

Or from the command line

If you use doctl, DigitalOcean's command-line tool, the settings are already written down in .do/app.yaml:

name: ai-primer
static_sites:
  - name: primer
    github:
      repo: your-account/your-repo   # the GitHub repo that holds these pages
      branch: main
      deploy_on_push: true           # rebuild the site after every change to main
    source_dir: /                    # or the folder that holds them, like /ai-primer
    build_command: zensical build --strict
    output_dir: site
    error_document: 404.html

Change the repo line (and source_dir, if the pages are in a folder), then:

doctl apps spec validate .do/app.yaml       # checks the settings, changes nothing
doctl apps create --spec .do/app.yaml       # makes the app

Keeping it up to date

Change the pages the usual way, yourself or with your assistant. Once a change is on main, DigitalOcean rebuilds the site within a few minutes.

  • Adding a page: save the new .md file, then add a line for it under nav: in mkdocs.yml. The build doesn't check this, so look for the new page in the menu afterwards.
  • Changing the menu: the order and the names down the side come from nav: too.
  • A build that fails leaves the last good version of the site up. The app's Activity tab in DigitalOcean shows the build log and why it stopped, which is nearly always a link that --strict caught. Running zensical build --strict on your own computer first catches it sooner.
  • Placeholders: write anything in angle brackets, like <your-account>, inside backticks. Outside them, a web browser takes it for a piece of the page's code, and it vanishes.

Its own address

To use a domain of your own, open the app in DigitalOcean, go to Settings, then Domains, and add it. DigitalOcean shows the record to add wherever your domain is managed, and sets up the secure https address by itself once that record is in place. Then fill in site_url in mkdocs.yml with the new address.

Who can find it

As it comes, the site asks search engines not to list it, so the people who find it are the people you give the link to. Anyone with the link can still read it, so treat it as public.

To let search engines list it, open mkdocs.yml and change noindex: true to noindex: false under extra:. Fill in site_url at the same time, which also gives search engines a list of every page.

What it costs

At the time of writing, App Platform hosts up to three static sites free, each with 1 GiB of data sent to visitors a month. Past that, each extra gigabyte costs a few cents. Check DigitalOcean's App Platform pricing page before you rely on it, since prices change.

For a sense of scale, this whole site is about half a megabyte the first time someone opens it, and much less on each page after that, because the browser keeps the parts every page shares. A free gigabyte covers a couple of thousand first-time visitors a month.

When something doesn't work

What's happening Likely cause, and the fix
DigitalOcean wants to charge for a web service The component was detected as a Python service. Edit it and change the type to Static Site.
The build says it can't find zensical DigitalOcean isn't looking in the folder that holds requirements.txt. Set the source directory to that folder.
The build says no version of zensical matches The build is using a Python older than 3.11. DigitalOcean's guide to building Python apps says how to choose the version.
The build stops with a warning about a link That's the strict check doing its job. Run zensical build --strict on your computer to see exactly which link.
A page is missing from the menu Add it under nav: in mkdocs.yml.
Something written in angle brackets is missing on the site Put it in backticks, like <this>.
The site looks right but the old version still shows Your browser kept a copy. Reload the page, or open it in a private window.

Back to the start · The technical setup · Next: How to contribute →