FORMDALL & ELEVENTY

Forms in Eleventy, without a plugin and without a server

6 min read·Eleventy 2 & 3

Eleventy does not ask you to configure anything. You put a few Markdown files in a folder, run npx @11ty/eleventy, and your site is sitting in _site/. You need neither an eleventy.config.js nor a scaffolding command, and there is no preset theme layout to work around. The config file stays optional as the project grows. That is why people stay with Eleventy: it has an opinion about almost nothing. The contact form is where you first feel that as a downside.

Why Eleventy holds up

Eleventy does not pick a template language for you. HTML, Markdown, Nunjucks, Liquid and JavaScript are in core, WebC comes as a plugin, and Handlebars, Mustache, EJS, Pug and HAML became plugins rather than core in Eleventy 3. You are not committing to one at project start; you mix them inside the same project: the listing page in Nunjucks, the articles in Markdown, one component in WebC. If you are coming from Jekyll, you will recognise the Liquid syntax - Jekyll’s own filters and tags like relative_url or {% post_url %} do not come along.

More interesting than the list of template languages is the layer underneath, the data cascade. The global data folder is called _data by default, and the file name is the key: whatever _data/site.js exports is available in every template under site. That file is plain JavaScript. It may export an object, a function, or an async function whose promise Eleventy awaits before rendering.

The comparison that matters is Hugo and Jekyll. Hugo has a well-thought-out data model, but you write the transform in Go templates: {{ range }}, {{ with }}, and a sort you express as a chain of pipes rather than as a comparison function. Jekyll gives you Liquid, which deliberately cannot do much; anything beyond it is a Ruby plugin in _plugins/. Both ask you to learn their dialect. In Eleventy, the answer to “how do I sort this differently” is a .sort(). And Eleventy 3 brought the rest up to date: ESM and CommonJS run side by side, and .ts files work too once Node can strip them (22.6+) or you put tsx in front.

Eleventy has its costs. Hugo is plainly faster and it is a single binary - one file with a checksum, which your CI downloads and starts. Eleventy is Node - package.json, a lockfile, node_modules, and a Node version that your laptop and your CI have to agree on. And Jekyll has an advantage Eleventy cannot match: GitHub Pages builds Jekyll natively, with no workflow file and no deploy token; for Eleventy you write an Action there. If your site is fifteen Markdown files and nobody on the team writes JavaScript, switching is not an improvement.

The build output is files

It shows up at the latest when you add a contact form. Eleventy runs, writes _site/ and exits. What is left is files: HTML, CSS, images. You upload them to Netlify, GitHub Pages or perfectly ordinary web hosting, where a web server serves them. When somebody hits submit later on, a POST goes to one of those files - and a host that serves static files answers it with a 405 Method Not Allowed at best, or in the worse case serves the same page again, which to the visitor looks as if the message went out.

That is the other side of the same bargain that brought you to Eleventy: there is nothing to configure because nothing runs at serving time. Eleventy has no runtime. Eleventy Serverless and Eleventy Edge existed under Eleventy 2; both were dropped in 3.0. That leaves none of the scaffolding a POST handler attaches to in other frameworks: a route here is only a file path, and there is nothing like a request lifecycle to attach to. In a framework with a server you would now add a file that handles POST, whereas Eleventy simply has no place for one. --serve will not help you there: the dev server rebuilds and refreshes the browser, and it is aimed at your local machine rather than at public traffic.

The data cascade is what trips people up here. A _data file may be async, and Eleventy awaits the promise, so you can call an API, though only at build time. The request goes out from your machine, before the page even exists. A form would need it the other way round, and hours later.

Wiring it up

An action that points at a foreign domain is as old as the <form> element itself. For Eleventy that means the endpoint is a project-wide constant like name or url, and project-wide constants live in the data cascade.

_data/site.js
// the file name is the key: this is available in every template under site
export default {
  name: "example.com",
  url: "https://example.com",
  formEndpoint: "https://api.formdall.de/api/v1/f/kx92m4",
};

export default assumes your project is on ESM, so "type": "module" in package.json or the .mjs extension. On Eleventy 2, and on Eleventy 3 in a CommonJS project, you write the same file as module.exports = { ... }. For staging that changes one line in this one file, and none of your templates has to know about it.

The form itself is an ordinary Nunjucks template. The comment inside it uses {# ... #}, because Nunjucks evaluates {{ ... }} and {% ... %} inside an HTML comment too:

contact.njk
---
layout: base.njk
---

{# endpoint comes from _data/site.js, not from the markup #}
<form action="{{ site.formEndpoint }}" method="POST">
  <label for="name">Name</label>
  <input id="name" name="name" required>

  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>

  <label for="message">Message</label>
  <textarea id="message" name="message" rows="6"></textarea>

  <button type="submit">Submit</button>
</form>

One template and one layout, and that is the whole of it: the form needs no client-side JavaScript, no plugin in eleventy.config.js, and your deploy step stays the one you already had. For several pages the block moves into _includes/.

The endpoint answers with a redirect to a target you set per form - /thanks/, say, which comes out of one more thanks.md in your input folder. If you would rather keep the visitor on the page, send the same POST with Accept: application/json and read the answer as JSON; the URL in _data/site.js stays the same in both cases. If you would rather not type the markup, create_form takes the name and the fields, and get_embed returns the finished block for the .njk file.

What you are not building

The POST lands on our endpoint instead of the static host that would have answered with a 405, and it runs through a chain of checks before it reaches your inbox. None of that puts a file in _site/. You are not embedding a third-party widget in a template, and since no cookies get set, there is no consent banner either.

The part your build never gets to see happens afterwards. Whatever the visitor sends off sits encrypted on servers in Germany. The application keeps only a hash of their IP that is different every day, and the server logs are gone after 14 days. If a form needs a hurdle, a self-hosted proof-of-work captcha does the work in the browser, without cookies or tracking. Access under Art. 15 and erasure under Art. 17 GDPR are one click per email address, and if the submissions also belong in your own system, the webhooks go out HMAC-signed and with SSRF protection. One example is an n8n webhook with an AI agent that scores every inquiry.

Building it yourself works. Just not in Eleventy. It would be a second project next to yours: a process waiting for the POST, plus SPF, DKIM and DMARC, bounces somebody reads, and spam rules that move with the next wave. Eleventy needs no configuration because nothing of it is left once the build is done; the second project has something running all the time, and it needs looking after just as often. The free tier covers three forms and 100 submissions a month, with no credit card.

OR: LET THE AI DO IT
YouBuild me a contact form for my Eleventy site using Nunjucks.
Assistant formdall · create_form formdall · get_embedForm created. Endpoint into the data cascade, template to go with it:
<form action="{{ site.formEndpoint }}" method="POST">
  <input name="name" required>
  <input name="email" type="email" required>
  <textarea name="message"></textarea>
  <button>Submit</button>
</form>
→ read the MCP docs

Create the endpoint, put it in _data

Start for freeno credit card, ever
  • Free
  • 3 forms
  • 100 submissions/mo