Low commit activity in last 3 years
A long-lived project that still receives updates
Adds a {% formspree %} Liquid tag to Jekyll that renders a Formspree contact form, using your own _includes/formspree.html template or a default one.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 3.8, < 5.0
 Project Readme

Jekyll Formspree

Gem Version Tests

A Jekyll plugin that adds a {% formspree %} Liquid tag to render a Formspree contact form.

Requires Jekyll 3.8 to 4.x and Ruby 3.1 or later.

Installation

Add the gem to your Gemfile:

group :jekyll_plugins do
  gem "jekyll-formspree"
end

then run bundle install. If you list plugins in _config.yml, add it there too:

plugins:
  - jekyll-formspree

GitHub Pages' built-in Jekyll build only runs allow-listed plugins. To use this plugin there, build the site with a GitHub Actions workflow.

Usage

Use your form ID, as shown on Formspree (https://formspree.io/f/<form ID>):

{% formspree "xyzabcde" %}

or read it from a variable, for example from _config.yml (formspree_id: xyzabcde) or from the page's front matter:

{% formspree site.formspree_id %}
{% formspree page.form_id %}

If the ID is empty, the build prints a warning.

Default form

Without a custom template, the tag renders:

<form class="formspree-form" action="https://formspree.io/f/xyzabcde" method="POST" accept-charset="utf-8">
  <label for="formspree-email">Your email</label>
  <input type="email" id="formspree-email" name="email" autocomplete="email" required>
  <label for="formspree-message">Your message</label>
  <textarea id="formspree-message" name="message" rows="5" required></textarea>
  <button type="submit">Send</button>
</form>

preceded by a few lines of CSS scoped to .formspree-form.

Custom form

Create _includes/formspree.html in your site (or in your theme). The tag renders it in the page's context, so page, site and {% include %} work as usual, with two extra variables:

Variable Value
formspree_id the form ID
formspree_url https://formspree.io/f/<form ID>
<form action="{{ formspree_url }}" method="POST">
  <input type="email" name="email" required>
  <textarea name="message" required></textarea>
  <input type="hidden" name="_subject" value="Message from {{ page.title }}">
  <button type="submit">Send</button>
</form>

Configuration

The endpoint prefix defaults to https://formspree.io/f/. To change it:

formspree:
  endpoint: https://formspree.io/f/

Upgrading from 0.0.x

  • The default form now posts to https://formspree.io/f/<id> instead of https://formspree.io/<id>. Use the form ID shown in your Formspree dashboard.
  • Custom templates keep working unchanged. To use the new endpoint, replace https://formspree.io/{{ formspree_id }} with {{ formspree_url }}.

Development

bundle install
bundle exec rake test
JEKYLL_VERSION="~> 3.10" bundle update jekyll && bundle exec rake test

License

MIT, see LICENSE.