WordPress to Cloudflare Workers: how I statically mirrored my entire site (and kept search & lightbox!)
I wanted to cache everything behind Cloudflare and stop worrying about PHP, MySQL, and plugin drift on my backup site cosmin.gq. I tried one-click export plugins (both the free and paid Simply Static), but I couldn’t get a clean export that behaved like the live site. So I rolled up my sleeves and wrote a Bash script that: crawls the site using the official sitemaps (including .gz children), mirrors HTML + assets incrementally, cleans up quirks like ?p= permalinks, generates a small search index (no dependencies, no bs4), adds a lightweight lightbox for images, and serves it all from Cloudflare Workers Static Assets with a smart router that understands /path, /path/, /path.html, and /path/index.html. Below is the story of how each section of the script came to be, what went wrong, what I learned, and why each piece is there. ...



