Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

One Node script, 124 pages in 19 languages, and a Markdown twin for every page

I build Deco My Tree, a free site where you make a Christmas tree, share the link, and friends leave notes that open on Christmas Day. Its public pages (the home page, countdowns, guides) are static HTML in 19 languages,

I build Deco My Tree, a free site where you make a Christmas tree, share the link, and friends leave notes that open on Christmas Day. Its public pages (the home page, countdowns, guides) are static HTML in 19 languages, and all of it comes from one zero-dependency Node script. This is how that script is organised, and the few decisions I would copy again.

The shape of it

The script is build.mjs plus a few small modules. Page copy lives in content/<locale>/*.mjs, one file per page. Renderers per page type live in pages/*.mjs. A lib/ folder holds the templating, the page shell and <head>, the JSON-LD, the date math and an inlined countdown engine. Running it writes every page plus sitemap.xml, robots.txt, llms.txt and the web manifest. The generated .html files are committed, so a deploy is a static asset upload.

Dates are the only moving part. The copy contains tokens such as the holiday year or a "days" placeholder. The first kind is filled at build time, and the second becomes a live value in the browser, computed in the visitor's own time zone. Because titles carry the year, I rebuild right after Christmas and right after New Year so 2026 rolls over to 2027.

Every page gets a Markdown twin

Next to deco-my-tree.html the build writes deco-my-tree.md. Each page links its twin in <head>, and every response carries the same pointer in a Link header, together with the API catalog, the OpenAPI document, the developer docs and llms.txt. This is the real header from a live page:

link: </deco-my-tree.md>; rel="alternate"; type="text/markdown", </.well-known/api-catalog>; rel="api-catalog", </openapi.json>; rel="service-desc"; type="application/vnd.oai.openapi+json", </developers>; rel="service-doc"; type="text/html", </llms.txt>; rel="describedby"; type="text/plain"

There is also an llms-full.txt, an openapi.json, a .well-known/api-catalog and an ai-catalog.json.

I can't prove that any of this changes whether an AI assistant cites the site. What I can say is that it costs one conversion function, the build keeps every twin in sync with its page, and an agent that wants plain text gets plain text instead of scraping markup.

Headers without 100 rules

On Cloudflare, _headers is limited to 100 rules, and a hand-written rule per page would hit that quickly. The build writes placeholder rules (/:page, /tr/:page and so on), so a new page gets its Link header without a new rule, and later rules take the hand-written pages and files out of the pattern. The build fails if the file would go over 100.

Checks that fail the build

Every build also checks the things I would otherwise break quietly: internal links, assets, exactly one <h1> per page, valid JSON-LD, hreflang pairs between languages, and the share images. Pages that share a key across languages are linked with hreflang automatically, so adding a language to a page means adding a file, not editing a list.

The pages never run a Worker

The app behind the tree links is a Cloudflare Worker, but the public pages never touch it. The build fails if the Worker is configured to run first for any of them, which keeps every page view a plain static asset request with no billed Worker request behind it.

The link-preview trick

A tree link needs a preview when someone pastes it into WhatsApp, Instagram or Facebook, and a preview only needs the page's og: tags. So two URL rewrite rules answer any request for /send-message that is not a browser opening the page (the Sec-Fetch-Dest: document header is missing) with a static copy that already contains the right card. One build step writes both the copies and the rules from a single list. The order matters: the copies go live first and the rules after, and to retire the trick you take the rules off first.

What I would copy

  • Keep the copy in code, one file per page, and let the build own every derived file: sitemap, Markdown twins, llms files, headers.
  • Make the build refuse to ship the things you will forget: a second <h1>, a broken hreflang pair, the 101st header rule.
  • Keep dynamic work out of the request path wherever a static copy will do.

If you want to see the result, the site is at decomytree.link, and the page for developers and AI agents, with the API and the MCP server, is at decomytree.link/developers.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.