Skip to content
FormSubmit

Eleventy

How to add a contact form to Eleventy (11ty)

Add a contact form to an Eleventy site using global data and a Nunjucks include, powered by a hosted form backend.

1 min readUpdated Sep 28, 2026

Eleventy outputs static HTML, so a contact form just needs its action set to a FormSubmit endpoint. Keep the endpoint in global data and render the form from an include.

1. Global data

_data/site.json
{
  "url": "https://example.com",
  "formsubmitEndpoint": "https://formsubmit.app/f/YOUR_FORM_ID"
}

2. Include

_includes/contact-form.njk
<form action="{{ site.formsubmitEndpoint }}" method="POST">
  <label>Name <input type="text" name="name" required></label>
  <label>Email <input type="email" name="email" required></label>
  <label>Message <textarea name="message" rows="5" required></textarea></label>
  <input type="hidden" name="_redirect" value="{{ site.url }}/thanks/">
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
</form>

3. Page

contact.md
---
layout: base.njk
title: Contact
---

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

Add a thanks.md page for the redirect, then configure the allowlist and notifications.

Frequently asked questions

Does it work with any Eleventy template language?

Yes. The form is plain HTML; the examples use Nunjucks but Liquid works the same way.

Keep reading

Your form backend is 60 seconds away

Sign in with Google, create a form, paste the endpoint. Free forever for small sites — no credit card.