# Migrating Hugo from Netlify to Cloudflare Workers (Handling Contact Forms, D1, Turnstile & Analytics)

**URL:** <https://discourse.gohugo.io/t/migrating-hugo-from-netlify-to-cloudflare-workers-handling-contact-forms-d1-turnstile-analytics/57547>\
**Category:** tips & tricks\
**Created:** [September 13, 2026, 8:34am UTC](https://discourse.gohugo.io/t/migrating-hugo-from-netlify-to-cloudflare-workers-handling-contact-forms-d1-turnstile-analytics/57547 "2026-09-13T08:34:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![idarek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/idarek/32/26229_2.png) [@idarek](https://discourse.gohugo.io/u/idarek)\
**Post date:** [September 13, 2026, 8:34am UTC](https://discourse.gohugo.io/t/migrating-hugo-from-netlify-to-cloudflare-workers-handling-contact-forms-d1-turnstile-analytics/57547/1 "2026-09-13T08:34:53Z")

</div>

Hi all,

I want to share my recent experience migrating my static Hugo website away from Netlify over to Cloudflare Workers.

While Netlify served me well for a long time, the restrictive free-tier limits – particularly around forms – pushed me to look for a more resilient, self-controlled setup. Cloudflare’s modern Workers architecture (serving static assets with edge functions) turned out to be an ideal match, but moving away meant rebuilding Netlify’s built-in “magic” form handling from scratch.

I put together a complete step-by-step walkthrough covering how to replicate and enhance that setup:

- **Static Assets + Backend Logic:** Serving Hugo static output while routing `/api/` endpoints directly to a lightweight Worker using `wrangler.jsonc` (`run_worker_first`).

- **Spam Protection:** Implementing Cloudflare Turnstile alongside honeypot fields to block scrapers and bots without intrusive captchas.

- **Submission Persistence:** Backing up form entries directly to a serverless Cloudflare D1 (SQLite) database before dispatching.

- **Transactional Delivery:** Routing emails via the Resend API with dynamic subjects, safe multi-destination routing, and automatic `reply-to` headers.

- **Privacy-First Analytics:** Dropping GA4 cookie banners in favour of Cloudflare Web Analytics injected seamlessly at the edge.

- **DNS & Routing Gotchas:** Handling the apex/`www` redirects cleanly via Redirect Rules and dummy IPs without running into HTTP 522 errors.

If you are running Hugo and considering a similar move, or simply want a robust, free-tier-friendly contact form backend without external third-party form builders, I hope this helps:

👉 **[The Complete Guide to Migrating Hugo from Netlify to Cloudflare Workers](https://dariusz.wieckiewicz.org/en/netlify-to-cloudflare-workers-migration/)**

Feedback, thoughts, or questions on the implementation are more than welcome!
