Written by: Geoffrey Callaghan
create a contact form with Jekyll
Create A Contact Form With Jekyll
To create a contact form on a Jekyll site using FabForm, follow these steps. Jekyll is a popular static site generator, and FabForm is a service for handling form submissions. Here’s a step-by-step guide to integrate a contact form into a Jekyll site using FabForm:
Set Up Jekyll Project:
gem install bundler jekyll
jekyll new my-website
cd my-website
bundle install
Create a Contact Page:
Create a new file named contact.md
in the root of your project (or in the _pages
directory if you have one).
Add the following content to contact.md
:
---
layout: page
title: Contact
permalink: /contact/
---
<h1>Contact Us</h1>
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
Configure FabForm:
Update Navigation:
_config.yml
or in an _includes
file, add the contact page to it. Here’s an example of adding it to _config.yml
:
theme: minima
title: My New Jekyll Site
navigation:
- name: "Home"
link: "/"
- name: "Contact"
link: "/contact/"
Test Your Site:
bundle exec jekyll serve
http://localhost:4000/contact/
to ensure your contact form appears correctly and can submit data.Deploy Your Site:
bundle exec jekyll build
_config.yml
):title: My New Jekyll Site
email: your-email@example.com
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://yourdomain.com" # the base hostname & protocol for your site
# Build settings
markdown: kramdown
theme: minima
navigation:
- name: "Home"
link: "/"
- name: "Contact"
link: "/contact/"
contact.md
):---
layout: page
title: Contact
permalink: /contact/
---
<h1>Contact Us</h1>
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
By following these steps, you will have a fully functional contact form on your Jekyll site that integrates with FabForm for handling submissions.