Skip to content
FormSubmit

GitHub Pages

How to add a contact form to GitHub Pages

GitHub Pages only serves static files. Here's how to add a working, spam-protected contact form anyway.

1 min readUpdated Sep 28, 2026

GitHub Pages only serves static files, so a contact form needs an external endpoint to receive submissions. Point the form's action at a FormSubmit endpoint and it works — FormSubmit stores the message, filters spam and emails it to you.

Steps

  1. Sign in to FormSubmit and create a form.
  2. Add the form to any HTML page in your repository (or your Jekyll/Hugo/Astro source):
contact.html
<form action="https://formsubmit.app/f/YOUR_FORM_ID" method="POST" class="fs-form">
  <div class="fs-field">
    <label for="fs-name" class="fs-label">Name</label>
    <input id="fs-name" type="text" name="name" placeholder="Jane Doe" required class="fs-input">
  </div>
  <div class="fs-field">
    <label for="fs-email" class="fs-label">Email</label>
    <input id="fs-email" type="email" name="email" placeholder="jane@example.com" required class="fs-input">
  </div>
  <div class="fs-field">
    <label for="fs-message" class="fs-label">Message</label>
    <textarea id="fs-message" name="message" rows="5" placeholder="How can we help?" required class="fs-input"></textarea>
  </div>
  <!-- Honeypot: leave this hidden field empty to catch bots -->
  <input type="text" name="_gotcha" tabindex="-1" autocomplete="off" style="display:none">
  <!-- Optional: where to send people after submitting -->
  <!-- <input type="hidden" name="_redirect" value="https://yoursite.com/thanks"> -->
  <button type="submit" class="fs-button">Send</button>
</form>

<style>
  .fs-form { max-width: 32rem; margin: 0 auto; display: grid; gap: 1.1rem; font-family: system-ui, sans-serif; }
  .fs-field { display: grid; gap: 0.35rem; border: 0; padding: 0; margin: 0; }
  .fs-label { font-size: 0.875rem; font-weight: 600; color: #18181b; }
  .fs-input { width: 100%; box-sizing: border-box; border: 1px solid #d4d4d8; border-radius: 0.5rem; padding: 0.6rem 0.75rem; font: inherit; font-size: 0.9rem; }
  .fs-input:focus { outline: 2px solid #6366f155; border-color: #6366f1; }
  .fs-choice { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
  .fs-help { font-size: 0.75rem; color: #71717a; margin: 0; }
  .fs-button { background: #18181b; color: #fff; border: 0; border-radius: 0.5rem; padding: 0.7rem 1rem; font-weight: 600; cursor: pointer; }
  .fs-button:hover { background: #27272a; }
</style>
  1. Commit and push. GitHub Pages rebuilds in a minute or two.
  2. In the form's settings, add yourname.github.io (and your custom domain, if any) to the allowlist.
  3. Submit a test.

Project sites

For project pages served at yourname.github.io/project/, the allowlist entry is still yourname.github.io — paths don't matter.

Using a static site generator

  • Jekyll (GitHub Pages' built-in generator): see the Jekyll guide.
  • Hugo, Astro, Eleventy and others via GitHub Actions: see the Hugo, Astro and Eleventy guides.

Keep your email private

With FormSubmit your email address never appears in the page source — unlike mailto: links or services that put your address in the form action — so scrapers can't harvest it.

Frequently asked questions

Why doesn't my form work on GitHub Pages?

GitHub Pages can't run server code, so there's nothing to receive a POST request. You need an external form backend.

Does it work with a custom domain?

Yes. Add both your custom domain and username.github.io to the allowlist if you use both.

Keep reading

Your form backend is 60 seconds away

Sign in with Google, create a form, paste the endpoint. Free forever for small sites — no credit card.