● READING · 1 MIN
Denver, CO
~/blog / this-blog-publishes-itself.md
awsci-cdhomelab

This blog publishes itself from Notion

I write posts in Notion. When I flip a status to Published, a webhook, a tiny Lambda and a GitHub Action turn it into static pages on this site in about two minutes. Here's how it fits together.

My site is plain HTML on S3 behind CloudFront, with no framework and no build step. I wanted a blog that kept it that way, but I also wanted to write somewhere nicer than a Markdown file in a git repo. So I write in Notion, and the site rebuilds itself when I hit publish.

The flow

  1. I set a post's Status to Published in Notion.
  2. Notion sends a webhook to a Lambda Function URL.
  3. The Lambda checks the signature, looks at the page, and decides whether the public blog actually changed.
  4. If it did, it fires a repository_dispatch event at my GitHub repo.
  5. A GitHub Action pulls every published post from the Notion API, renders static HTML, syncs blog/ to S3 and invalidates CloudFront.

Nothing polls. Drafts are ignored, and flipping a post back to Draft takes it down the same way.

Checking the webhook is really from Notion

The Function URL is public, because Notion can't sign AWS requests. Every event carries an HMAC of the body instead, which the Lambda verifies before doing anything:

javascript
const expected = "sha256=" + createHmac("sha256", verificationToken).update(rawBody).digest("hex");
return timingSafeEqual(Buffer.from(expected), Buffer.from(header));
⚠️Notion's file URLs expire after about an hour, so the build downloads every image into the site instead of hot-linking it.

Why not just use a blogging platform?

  • Posts look exactly like the rest of the site.
  • All the search traffic lands on my own domain.
  • It costs effectively nothing to run.

What I'd change next

Pretty URLs (dropping the .html) and syntax highlighting for code blocks are next on the list.

This post was published by setting its status in Notion. If you're reading it, the pipeline works.