Contact form for Jekyll
Contact form for a Jekyll site
Jekyll builds static HTML, so it can't receive form posts by itself. Put a form in an include, point it at Formpit, and submissions are emailed to you and stored in an inbox. Works on GitHub Pages without any plugins.
How to set it up
- Create a free form in Formpit and copy its endpoint URL.
- Save the snippet as
_includes/contact-form.html, then add{% include contact-form.html %}to any page or layout. - Add
formpit_endpointto_config.yml, build, deploy and send a test from the live site.
_includes/contact-form.html
<!-- _includes/contact-form.html -->
<form action="{{ site.formpit_endpoint }}" 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="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
<input type="hidden" name="_redirect" value="{{ '/thanks/' | absolute_url }}">
<button type="submit">Send</button>
</form>Replace YOUR_FORM_ID with the endpoint from your form's Setup tab.
_config.yml
# _config.yml
formpit_endpoint: https://formpit.com/f/YOUR_FORM_IDGood to know
- Keeping the endpoint in
_config.ymlmeans one place to change it for every form on the site. - Jekyll on GitHub Pages runs in safe mode, which is fine: this needs no plugins.
Using the include on any page
Once the include is saved, add {% include contact-form.html %} to a page, a post or a layout. Because the endpoint lives in _config.yml as site.formpit_endpoint, you can change it in one place. Restart jekyll serve after editing _config.yml; it isn't reloaded automatically.
Several forms on one site
Create one Formpit form per purpose, such as contact and quote requests, and pass the endpoint into the include: {% include contact-form.html endpoint=site.quote_endpoint %}, with action="{{ include.endpoint | default: site.formpit_endpoint }}" in the include. Each form gets its own inbox and settings.
Testing locally
Forms submit from localhost too, so you can test before deploying. If you lock the form to your domain in Formpit's settings, add your local address as well, or test on the live site.
What you get
- Every submission emailed to you and stored forever in an inbox with New / Replied / Closed statuses.
- Reply from the inbox, add tags and notes, search, export CSV or JSON.
- Spam filtering with a honeypot, rate limiting and content checks; hCaptcha, reCAPTCHA or Turnstile if you want it.
- 500 submissions a month free. Pro adds file uploads, Google Sheets, Notion, Slack, webhooks and reminders.
Questions
Does this work on GitHub Pages?
Yes. It needs no Jekyll plugins, so it works in GitHub Pages' safe mode.
Can I use a Jekyll data file for the form fields?
Yes. Loop over a YAML list in _data to output the inputs; Formpit receives whatever fields have a name.
Other platforms
Lovable · Bolt · v0 · WordPress · Shopify · Wix · Squarespace · Framer · Webflow · Carrd · Plain HTML · React · Next.js · Astro · Hugo & Eleventy · Vue & Nuxt · Svelte & SvelteKit · GitHub Pages