All guides

GitHub Pages guide

A contact form that works on GitHub Pages

GitHub Pages only serves static files, so a form has nowhere to send its data. Post it to Formcrate instead: it works for plain HTML, Jekyll, or any framework you build and deploy to Pages.

  1. 1Create a form and copy its key

    Sign up with Google, create a form and enter the email address that should receive submissions. Copy the form key from the dashboard: it replaces YOUR_FORM_KEY below. The free plan includes 500 submissions a month.

  2. 2Add the form to your page

    Replace USERNAME with your GitHub username (or your custom domain) so visitors come back to your site after sending.

    index.html
    <form action="https://www.formcrate.dev/api/submit/YOUR_FORM_KEY" method="POST">
      <input type="text" name="name" placeholder="Name" required />
      <input type="email" name="email" placeholder="Email" required />
      <textarea name="message" placeholder="Message" required></textarea>
      <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off" />
      <input type="hidden" name="redirectTo" value="https://USERNAME.github.io/thanks.html" />
      <button type="submit">Send</button>
    </form>
  3. 3Add a thank-you page

    Commit a thanks.html next to index.html. It can be as simple as a heading and a link home.

    thanks.html
    <!doctype html>
    <title>Thanks!</title>
    <h1>Thanks, your message was sent.</h1>
    <p><a href="/">Back to the site</a></p>
  4. 4Send a test submission

    Fill in the form on your site and submit it. The message appears in your Formcrate inbox and arrives by email within a few seconds. Anything that looks like spam goes to the Spam tab instead and isn't emailed.

  5. 5Lock the form to your domain

    Your key is visible in the page source, which is normal for form backends. In the form settings, add your domain under Domain lock so other websites can't post to your form from the browser.

Tips

  • Your key ends up in a public repository, which is fine: it can only create submissions. Lock the form to USERNAME.github.io (and your custom domain) in its settings.
  • Using Jekyll on Pages? See the Jekyll guide to keep the key in _config.yml.

Get your GitHub Pages form working

Free for 500 submissions a month. Spam filtering, email alerts and an inbox included. No card required.

Create a free form

Guides for other stacks