Skip to content
FormToMail

Static sites & frameworks

How do I add a working contact form to an 11ty (Eleventy) site?

By the FormToMail team · Checked against official sources · Updated

Eleventy is a static site generator, so a contact form is plain HTML in an include or template whose `action` is a form endpoint. Nothing to install: the form posts straight to the endpoint, which emails you and redirects the visitor back to a thank-you page.

Eleventy hosting and forms
HostBuilt-in forms?Use
NetlifyNetlify FormsNetlify Forms or an endpoint
Cloudflare Pages, GitHub Pages, VercelNoAn endpoint (or your own function)

_includes/contact.njk

html
<form action="https://getformtomail.com/f/YOUR_FORM_ID" method="POST">
  <input name="name" required>
  <input name="email" type="email" required>
  <textarea name="message" required></textarea>
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
</form>

Quick answers

How do I add a working contact form to an 11ty site?

Put the HTML above in an include and use a form endpoint as the action.

How do I add a form to a vue static site?

Same idea: a form posting to an endpoint, or fetch() from a component.

How do I add a form to svelte or sveltekit static build?

With adapter-static there are no form actions on the server, so post to an endpoint with fetch() or a plain action.

What to do next

Create an endpoint for your Eleventy include.

Get your form endpoint

Sources

Checked: . Prices, limits and features of other services change: confirm current values at the official links above. Product names belong to their owners; we are not affiliated with them.