# 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-16. Web version: https://wrenform.com/docs/frameworks/eleventy

```njk
<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

1. [Create a form](/sign-in) and copy its form ID, or let your AI tool create one [without an account](/docs/quick-forms).
2. Set the form ID once, in the global data file `_data/site.json`:

```json
{
  "wrenformId": "YOUR_FORM_ID"
}
```

3. Save the snippet as `_includes/contact-form.njk`.
4. Add the include where the form should appear, for example in `contact.md` with `permalink: /contact/` in its front matter:

```njk
{% include "contact-form.njk" %}
```

5. Add a thank-you page, for example `thanks.md` with `permalink: /thanks/`, and set it as the form's **Success URL** (see [redirects](/docs/redirects)).
6. 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.** `wrenformId` is 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, including `https://`, 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](/docs/troubleshooting): symptom, cause and fix.
- [Spam](/docs/spam): the honeypot, and the optional helper script that adds a timing check.
- [Fields](/docs/fields): subjects, reply-to and lists.
- [Errors](/docs/errors): every code and its fix.
