Contact forms / Eleventy
Eleventy (11ty) contact form without a backend
One include with a plain HTML form, and the form ID set once in your global data. No plugin, no serverless function, no JavaScript.
Why Eleventy needs a form backend
Eleventy outputs static HTML. That's why 11ty sites are fast and cheap to host, but it also means nothing on the site can receive a contact form. The usual fixes are a serverless function with an email API key, or a host's own forms feature that ties you to that host.
With Wrenform the form's action points at your endpoint, and the visitor's browser posts straight to us. We store each submission, filter spam and email your recipients. Your 11ty build stays plain HTML and deploys anywhere.
The prompt
The include reads the form ID from site.wrenformId in _data/site.json, so every page that includes it posts to the same form. It holds no template comment, so it works in Nunjucks and Liquid.
<form action="https://wrenform.com/f/{{ site.wrenformId }}" method="POST">
<label>Name <input type="text" name="name" autocomplete="name" required></label>
<label>Email <input type="email" name="email" autocomplete="email" required></label>
<label>Message <textarea name="message" required></textarea></label>
<input type="text" name="_honey" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send</button>
</form>Steps
- Create a form (free) and copy its form ID. No account yet? Ask your AI tool to create a quick form with
framework: "html": one request returns your endpoint and a ready snippet. Click Confirm in the email from Wrenform, and messages start arriving. - Add
"wrenformId": "YOUR_FORM_ID"to_data/site.json(create it if it doesn't exist). - Save the snippet as
_includes/contact-form.njkand add{% include "contact-form.njk" %}to your contact page. - Build, deploy, and add your site to Allowed origins.
Spam handling
Spam filtering is on for every form, with no CAPTCHA: a hidden honeypot field, a timing check, rate limits per visitor, and a content score for links, keywords and gibberish. Spam goes to a separate tab and is never emailed. See how spam filtering works.
After sending, the visitor lands on our thank-you page. To use your own, add a thanks.md with permalink: /thanks/ and set it under Redirect to in the form's settings. See redirects.
Where messages go: every real submission is emailed to your recipients and kept in the dashboard inbox. On Pro and Agency plans, a webhook can also send each one to your own server.
Deployment notes
- Netlify. Deploy as usual. Netlify only processes forms that carry its own
netlifyordata-netlifyattribute, so it leaves this form alone and the browser posts it to Wrenform. Add yournetlify.appaddress and your custom domain to Allowed origins. - Vercel. Nothing to configure. The Eleventy build stays static; you don't need a serverless function for the form. Add your production domain to Allowed origins. Preview deployments get their own addresses, so leave the list empty while you test them, or add each one.
- Cloudflare Pages. No Pages Function needed. Add your
pages.devaddress and your custom domain to Allowed origins. If you set a Content-Security-Policy header, addform-action https://wrenform.com. - GitHub Pages. GitHub Pages serves static files only, which is all this form needs. Add
https://<user>.github.io(or your custom domain) to Allowed origins. The origin is the host only, without the repository path.
The 11ty data file
If your site already has _data/site.json (or site.js), add the wrenformId key to it instead of creating a second file. Data files are case-sensitive, so the key must match the include. The Eleventy guide walks through the include, the thank-you page and testing.
{
"wrenformId": "YOUR_FORM_ID"
}FAQ
Does an 11ty contact form need a serverless function?
Does the include work in Liquid as well as Nunjucks?
Does it work with eleventy --serve?
Next steps
- The full Eleventy guide: every option, testing, and common problems.
- Jekyll contact form without a plugin
- Contact form for Hugo without a server
- Pricing: free for 250 submissions a month.