Add a contact form to an 11ty site with a Formcask endpoint. No Netlify Function or custom API route required.
Eleventy builds HTML. Put the form in a Nunjucks, Liquid, or plain HTML template (for example _includes/contact-form.njk):
<form action="https://formcask.com/f/f_YOUR_FORM_ID" 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" required></textarea></label> <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off"> <input type="hidden" name="_redirect" value="https://yoursite.com/thanks/"> <button type="submit">Send</button> </form>
Use a full https:// thank-you URL. Relative paths are not accepted for _redirect. Rebuild with npx @11ty/eleventy as usual. You do not need an Eleventy serverless function or a host-specific form feature.
JSON fetch() also works from client-side JavaScript, with Accept: application/json. File uploads require the Pro plan and multipart/form-data.
Related: Plain HTML · Hugo · Jekyll · Netlify