Skip to main content
Source Version

These docs are based on gwern.net commit 4d6661114 (2026-07-02); all pages were audited against that commit's source in 2026-07.

gwern.net Codebase Documentation

This is an unofficial map of the gwern.net codebase: how Markdown essays move through the Hakyll/Pandoc build, how link metadata becomes annotations, and how the frontend turns static HTML into interactive pages.

Quick Start

If you want to...Start here
Get the system modelArchitecture at a Glance
Follow one page from source to browserPage Lifecycle
Find the file responsible for a featureFunctional Taxonomy

If you are new to the codebase, read the architecture overview first, then use page lifecycle for the end-to-end flow and functional taxonomy as the map of individual files.

Guided Topics

These are shorter paths through the larger reference when you already know what subsystem you care about.

TopicStart hereCovers
Build pipelineBuild PipelineHakyll, Pandoc, generated content, validation, and deployment
Annotation metadataAnnotation and MetadataGTX records, metadata scrapers, annotation fragments, and frontend loading
Popup systemPopup SystemHover previews, mobile popovers, Extracts dispatch, transclusion, and annotation display

What is gwern.net?

gwern.net is a long-form essay site by pseudonymous writer Gwern Branwen, with frontend work by Said Achmiz. It is known for long, heavily cited essays and for a site design that treats the web page as an extended reading environment rather than a simple document.

The codebase is interesting because many of the reading features are custom infrastructure: hover popups for citations and local pages, inline transclusion, margin sidenotes, generated bibliographies, annotation databases, and link archiving.

The backend is built around Hakyll and Pandoc, with Haskell modules handling metadata, transforms, validation, generated pages, and deployment support. The frontend is vanilla JavaScript built around an event system that coordinates popups, transclusion, theming, layout, and other runtime behavior.

Why This Exists

Gwern has written about the site's design in About This Website, Design Graveyard, and Typography. This reference is meant to complement those essays by organizing the source code itself: what the major modules do, where features enter the pipeline, and how the build-time and runtime systems fit together.

Use it as a companion while reading the upstream source, or as a routing layer when asking an agent to inspect a subsystem. These docs are source-derived but unofficial; the codebase changes often, and the source remains the authority.

How These Docs Were Created

To create the docs, I first built a rudimentary map with notes I wrote while reading the codebase. I then fed this map to multiple Claude Opus 4.5 agents, with each cohort documenting a different part of the codebase. I manually reviewed the output and did a secondary fact-checking step with GPT 5.2 and Claude again.

Disclaimer

Every now and then I find a new mistake or a not-quite-accurate description. These docs are by no means authoritative, comprehensive, or fully correct. If you find any problems or inaccuracies, feel free to contact me and I'll correct them as soon as possible.


Documentation Structure

The overview section has three layers: Architecture at a Glance for the system model, Page Lifecycle for the chronological flow, and Functional Taxonomy for the full file map with importance scores.

CategoryDescription
OverviewHigh-level architecture, page lifecycle, and functional taxonomy
Build PipelineCore build scripts (sync.sh, hakyll.hs, bash.sh)
Annotation & MetadataLink metadata system, scrapers, and processing
Popup SystemPopups, popovers, and extract handling
Link ProcessingArchives, icons, auto-linking, and interwiki
Content RenderingCore JS framework, transclusion, and DOM rewriting
Typography & LayoutText transforms, sidenotes, columns, and images
Theming & UIDark mode, reader mode, colors, and CSS
Backend UtilitiesHaskell helper modules
Frontend UtilitiesJavaScript helper modules
Tags & NavigationTag management and directory generation
Content FeaturesBlog, X-of-the-day
PHP Asset PipelineCSS/JS bundling and asset generation
Python UtilitiesLLM-based text processing tools
Shell UtilitiesEmbedding, archiving, uploading scripts
HTML TemplatesHakyll/Pandoc templates
Server & NginxServer configuration
If you want to...Start here
Understand the JS architectureinitial.js
Understand popupspopups.js
Understand annotationsLinkMetadata.hs
Understand the buildsync.sh