How to add a contact form to a static website.

A static website can show a contact form but can’t process one, because there is no server to receive the submission. To make the form work, point it at something that can: a form backend service, your host’s built-in forms, a serverless function, or an embedded third-party form.

Static sites are fast, cheap to host and hard to break, which is why so many small-business sites are now plain HTML or come out of a generator such as Astro, Hugo, Eleventy or Jekyll. The one thing they can’t do alone is the thing a business site needs most: take a message from a visitor and get it to you. Here is why, and the four practical ways to fix it.

Why doesn’t a form work on a static site?

An HTML form only collects what the visitor typed. When they press Send, the browser packages the fields and posts them to the address in the form’s action attribute. Something at that address has to receive the data and do something with it: send an email, save it, pass it to another tool. On a traditional site that is your own server. A static host, such as GitHub Pages, only hands out files. It has nothing that can receive a submission, so a form pointed at your own site simply fails.

Visitorfills in the formBrowserposts the fieldsForm backendchecks for spamYouemail, Slack, inbox
What happens when a visitor presses Send. The static site only supplies the first two steps.

A mailto: link is sometimes used as a workaround. It opens the visitor’s own email program, which many people haven’t set up, and it publishes your address to every spam harvester. It isn’t a form.

What are the options?

  • A form backend service. You keep your own HTML form and point its action at the service. The service receives each submission, filters spam and emails it to you. It works on any host and needs no code beyond the form itself.
  • Your host’s built-in forms. Some static hosts, Netlify among them, can detect forms in your pages and collect submissions for you. It’s convenient if you’re already there, but it ties the form to that host, and GitHub Pages has nothing like it.
  • A serverless function. You write a small function on a platform such as Cloudflare Workers or AWS Lambda that receives the post and sends the email through a mail provider. You get full control, and you also get the work: validation, spam protection, email deliverability, error handling and maintenance.
  • An embedded form. Form builders give you an iframe or script to paste in. It’s quick, but the form usually doesn’t match your site’s design, loads someone else’s scripts and can be slower and less accessible.

For a typical small-business contact or quote form, a form backend is the shortest path: your design, your HTML, and nothing to run.

What does the HTML look like?

With a form backend, the form is ordinary HTML. The address and any key come from the service you choose; the address below is a placeholder.

<form action="https://forms.example.com/submit" method="POST">
  <label for="name">Name</label>
  <input id="name" name="name" autocomplete="name" required>

  <label for="email">Email</label>
  <input id="email" name="email" type="email" autocomplete="email" required>

  <label for="message">How can we help?</label>
  <textarea id="message" name="message" rows="5" required></textarea>

  <button type="submit">Send message</button>
</form>

Three details matter. Every field needs a name, because that is the label the submission arrives with. Every field needs a visible <label> tied to it with for and id, so screen readers and phone keyboards handle it properly. And type="email" with required lets the browser catch empty and mistyped fields before anything is sent.

A person’s hand on a laptop trackpad at a white desk, seen from above.
A plain HTML form needs no framework and no build step. Photo: Štefan Štefančík on Unsplash

What should happen after someone submits?

A plain form post moves the visitor to a new page, so send them to a thank-you page on your own site that says what happens next and how soon you’ll reply. Most services let you set that address. If you’d rather keep them on the same page, submit the form with JavaScript and show a confirmation message in place, but make sure the form still works if the script fails to load.

Either way, send a test submission before the site goes live, and check that the email arrives and isn’t sitting in your spam folder.

How do you keep spam out?

Any public form attracts bots within days. Layer a few defences, none of which bother real visitors much:

  • A honeypot field: a field hidden from people that bots fill in anyway. Submissions with it filled are dropped.
  • A challenge such as Cloudflare Turnstile, which checks the visitor in the background and rarely shows a puzzle.
  • An allowed-sites list, so the endpoint only accepts posts from your own domain.
  • Rate limits per visitor.

Never let a form field decide where the email goes. A form that sends to whatever address is in a hidden field can be turned into a spam relay.

What about privacy?

A contact form collects personal information, so say what you do with it. Collect only the fields you need, link your privacy policy next to the Send button, and decide how long submissions are kept. Privacy rules differ by state and country, so if you serve visitors outside your own state, check which ones apply to you.

How FormRelay fits

FormRelay is DomoDomu’s form backend for static websites. It’s in early access, and the free plan is open for sign-up now. You sign up, confirm the email address that should get your leads, and copy your form’s snippet into your page; the setup page has snippets for HTML, JavaScript, React and Astro. Each submission is emailed to the addresses you’ve confirmed, kept in an inbox with CSV export, and can be sent on to Slack, Discord or a signed JSON webhook, up to five per form.

Spam is handled with a hidden honeypot field, Cloudflare Turnstile using your own keys, an allowed-sites list and per-visitor limits; what gets caught is filed under Spam and never emailed. Every email and webhook is logged and retried when a provider is down.

The free plan covers 250 submissions a month. Pro is $12 a month for 10,000 and Business is $29 a month for 50,000, and every plan includes every feature. What it doesn’t do yet: file uploads, an automatic reply to the person who filled in the form, sending from your own domain, and hCaptcha or reCAPTCHA. See FormRelay pricing and how it works.

Your form, working today.

FormRelay is in early access. The free plan covers 250 submissions a month with every feature and is open for sign-up now; Pro is $12 a month and Business is $29.