← Back to Blog

Sixty-Six Static Pages Built With Nothing but Node

AnnMax · November 25, 202610 min read

A Build Script, Not a Framework

The site my Windows tools download from is sixty-six HTML files from one command — sixty pages across the six languages, plus three legal pages that exist only in English and Chinese. Its package.json holds two scripts and zero dependencies: npm run build is literally node src/build.mjs, and deploy hands dist/ to wrangler pages deploy on Cloudflare Pages. Delete node_modules and it still builds.

I tried the usual generators first, and each cost more time than the site did — a config format to memorise and a template language layered over HTML. A static site only needs a function that takes a language and a page and returns a string, so that is what I wrote: src/html.mjs builds the shell, each file in src/pages/*.mjs returns a body as a template literal, and one nested loop writes everything.

for (const lang of LANGS) {
  const t = texts[lang.code];

  for (const page of pages) {
    const html = layout({ ... });
    writeFile(path.join(lang.prefix, page.file), html);
    written++;

Ten page kinds across six languages is sixty files; the legal pages exist only in English and Simplified Chinese, adding six more. The build prints the per-language count so a missing language shows in the log, then warns if a product's stated size differs from the installer on disk by more than 0.6 MB — a page that lies about the file it serves is a support ticket.

Every Language Is a Real File

The comment at the top of the build script is the reason it exists: six language versions need to be crawlable, and swapping text at runtime means search engines only ever see the English one. There is no client-side i18n here — /ja/keyguard is a file that contains Japanese.

The language table is one array: English hangs off the root path, zh, ja, ko, de and fr get a prefix. There is no Spanish here even though my extension pages ship it — Korean is there because that traffic exists. Adding or dropping a language is one line, and every page, redirect and hreflang set follows it.

Copy lives in six JSON files of just over a thousand lines each, and a missing key must never render undefined, so English is deep-merged under every locale:

function withFallback(base, over) {
  if (over === undefined) return base;
  if (base === null || typeof base !== 'object' || Array.isArray(base)) return over;
  const out = { ...base };
  for (const k of Object.keys(over)) out[k] = withFallback(base[k], over[k]);
  return out;
}

The only runtime language logic is a one-time redirect, fenced to the root path: someone who lands on /de/catalog from a search result already picked German. localStorage only remembers a manual switch so the guess never overrides a decision.

if (location.pathname !== '/') return;
if (localStorage.getItem('vkt-lang')) return;
var nav = (navigator.languages && navigator.languages[0]) || navigator.language || 'en';

hreflang alternates list only the languages that genuinely have that page, plus x-default at English; a declaration resolving to a 404 is worse than none. The sitemap has no xhtml:link at all, which took an afternoon to diagnose: once it carries the xmlns:xhtml namespace and xhtml:link children, Chrome drops its XML viewer and renders the file as flat text — tags discarded, bare URLs, looking exactly like a broken build. The per-page alternate links carry the language graph instead, and _headers forces text/xml on /sitemap.xml, since Pages would send application/xml and do the same.

The Download URL Follows the Bytes

No version number is typed anywhere in the site. At build time each product's version is regex'd out of its C# project file:

function readVersion(relPath) {
  const file = path.resolve(siteRoot, relPath);
  if (!fs.existsSync(file)) return '0.0.0';
  const m = fs.readFileSync(file, 'utf8').match(/<Version>([^<]+)<\/Version>/);
  return m ? m[1].trim() : '0.0.0';
}

The installer's SHA-256 isn't computed here either: the packaging script writes a .exe.sha256 sidecar beside the artifact and the build reads the 64 hex digits out of it. That hash becomes a query parameter on the download URL, truncated to twelve characters:

function readAssetTag(sha256) {
  return sha256 ? `?v=${sha256.slice(0, 12)}` : '';
}

Here is the failure that produced it. I shortened a trial from fourteen days to seven and rebuilt without bumping the version, so the artifact overwrote the same filename — and /downloads/* is cached for a day at the edge, so the CDN went on serving the fourteen-day installer until that day aged out. Making the address follow the content ends that: a different build is a different cache key, and I never inflate a version number just to bust a cache. Pages, emails and store listings use a versionless short link, which the build rewrites to today's real file:

for (const p of products) {
  const exe = `/downloads/VKT-${p.name}-${p.version}-x64-Setup.exe${p.assetTag}`;
  redirectLines.push(`/downloads/${p.name}.exe  ${exe}  302`);

The one-day header applies only to /downloads/VKT-* — the real files. The short link is excluded: cache a 302 for a day and the redirect itself goes stale, which is the same bug with an extra hop.

Stylesheets had the same failure mode: /css/site.css was a fixed URL cached for hours, so after a style change a visitor got new HTML with the old stylesheet and the page fell apart. It is now emitted as site.<ten hash chars>.css with an immutable year-long header; the unhashed name keeps a ten-minute cache for links already out there.

The hash appears on the product page in uppercase, beside the Get-FileHash command that verifies it: both that and certutil print uppercase, and asking someone to case-convert 64 characters guarantees nobody checks. The stored value stays lowercase, since updates.json and the ?v= parameter consume it.

One Table of Facts

src/site.mjs holds one PRODUCTS array, the only place a product exists: slug, executable name, path to its .csproj, approximate size, trial days, price and strikethrough list price. The comment on the pricing block states the point — promo copy only says "launch price", never a number, so a price change is one field and every page, button and schema node moves with it. Trial and offline-grace days sit in two constants, and the Microsoft Store link hangs off the one product listed there, with no locale parameters so whoever opens it gets their own language.

The same discipline governs JSON-LD, under three rules written above it. Never emit aggregateRating: there are no real ratings, and inventing one to earn star results is spammy structured markup that only has to be caught once to hurt the domain. Never hardcode a price, version or URL, because it drifts from the installer within a release — operatingSystem, softwareVersion and the offer's url are derived at build time. And never keep a second set of FAQ copy "for Google": the schema uses the array the page renders.

updates.json is the same data with another consumer: the client's check-for-updates, the download page and support all read that one file. Its download field is the unversioned short link on purpose, so a client that stored it still works releases later; its cache time is five minutes, because "still reports 0.4.0 the day after a release" is indistinguishable from "the release never happened".

What the Copy Costs

Three places where the build's job is to state something unfavourable in six languages rather than hide it.

The installers aren't code-signed yet, so SmartScreen interrupts the first run; a fixed line under the buy card says what to click — More info, then Run anyway. Activation needs a network connection and no offline codes are issued, which the licence copy states, along with the machine identifier being a hardware-derived hash. When I renamed one product, the internal key stayed put because it prefixes backend plan keys while only the public URL moved; the old paths get 301s at the very top of _redirects, since Cloudflare honours only the first matching rule.

None of it is clever code: sixty-six files whose facts arrive from one table, one version regex and one hash sidecar — plus a build log that complains when they stop agreeing.

Related Articles