Docs / Frameworks
Contact form for Eleventy
An Eleventy include with a plain HTML form, and the form ID set once in _data/site.json. Works on any static host.
Last updated 2026-11-16View as Markdown
<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 and copy its form ID, or let your AI tool create one without an account.
- Set the form ID once, in the global data file
_data/site.json:
{
"wrenformId": "YOUR_FORM_ID"
}- Save the snippet as
_includes/contact-form.njk. - Add the include where the form should appear, for example in
contact.mdwithpermalink: /contact/in its front matter:
{% include "contact-form.njk" %}- Add a thank-you page, for example
thanks.mdwithpermalink: /thanks/, and set it as the form's Success URL (see redirects). - Build and deploy as usual. Then add your site's origin under Allowed origins in the form's settings.
The include works in Nunjucks and Liquid templates, and in Markdown pages (Eleventy runs them through a template language first). Eleventy has no server, and it doesn't need one here: the visitor's browser posts the form to Wrenform.
If your site already has a _data/site.json (or site.js), add the wrenformId key to it instead of creating a second file.
Test it
Run npx @11ty/eleventy --serve, open /contact/ and send the form. You should land on your thank-you page, see the submission in your dashboard and get an email. While testing locally, leave Allowed origins empty or add http://localhost:8080.
Common problems
- The form posts to
/f/with no ID.wrenformIdis missing from_data/site.json, or the key is spelled differently. Data files are case-sensitive. - The page shows
{% include %}as text. The page's template language is off (templateEngineOverride: md). Remove the override, or move the include into a layout. origin_not_allowed. Add the site's origin, includinghttps://, to the form's allowed origins.- You see Wrenform's own thank-you page. Set the form's Success URL to your
/thanks/page.
Next steps
- My form isn't working: symptom, cause and fix.
- Spam: the honeypot, and the optional helper script that adds a timing check.
- Fields: subjects, reply-to and lists.
- Errors: every code and its fix.