Un-static

how-to

Add a Contact Form to GitHub Pages (Free, No Backend)

A step-by-step walkthrough on adding a contact form to your static Github Pages

Short answer

GitHub Pages only serves static files, so it cannot process a form submission itself. Point your form’s action at a form backend such as Un-static and submissions arrive in your inbox by e-mail. Copy the contact.html snippet below into your repository and push.

Updated October 2026.

GitHub Pages hosts a site straight from a GitHub repository. Sites are built with Jekyll by default, or served as plain HTML when you add a .nojekyll file. Either way there is no server code you control, so a contact form needs an external handler to receive what your visitors send.

Add a contact form step by step

Step 1. Register a form and confirm your e-mail address. The form asks for a Success Destination, the page your visitors land on after sending, such as a thank-you page on your site. You get a form endpoint in return.

Step 2. Copy the code below into a file called contact.html in your repository. For a Jekyll site, see the Jekyll section first.

Step 3. Replace YOUR_ENDPOINT_REFERENCE with the reference of your form endpoint.

Step 4. Commit the file and push it to GitHub:

git add contact.html
git commit -m "Add contact form"
git push

GitHub Pages republishes your site after the push. Open /contact.html on your site, send yourself a test message and check your inbox. After you press Send, you first pass our reCAPTCHA protection page on forms.un-static.com (the default spam protection) and then land on your Success Destination.

Step 5 (optional). Link the form to a free account, open it in your dashboard and go to Security Settings. Under Set Honeypot Field, enter website, the hidden field in the code below. See spam protection for what it does.

The free plan covers everything on this page. See plans and pricing for the limits.

The contact.html file

A complete page with plain HTML and a few lines of CSS, so it looks tidy when you paste it as is. No framework, no JavaScript.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Contact me</title>
  <style>
    .contact-form {
      max-width: 32rem; margin: 2rem auto; padding: 0 1rem;
      font: 1rem/1.5 system-ui, sans-serif;
    }
    .contact-form label { display: block; margin-top: 1rem; font-weight: 600; }
    .contact-form input, .contact-form textarea {
      box-sizing: border-box; width: 100%; margin-top: .25rem; padding: .6rem;
      border: 1px solid #999; border-radius: 4px; font: inherit;
    }
    .contact-form button {
      margin-top: 1.25rem; padding: .6rem 1.4rem; border: 0; border-radius: 4px;
      background: #1d4ed8; color: #fff; font: inherit; cursor: pointer;
    }
    .contact-form .hp { position: absolute; left: -10000px; }
    .contact-form small { display: block; margin-top: 1.5rem; color: #666; }
  </style>
</head>
<body>
  <form class="contact-form" method="post"
        action="https://forms.un-static.com/forms/YOUR_ENDPOINT_REFERENCE">
    <label for="name">Name</label>
    <input id="name" name="name" type="text" required>

    <label for="email">E-mail address</label>
    <input id="email" name="email" type="email" required>

    <label for="message">Message</label>
    <textarea id="message" name="message" rows="6" required></textarea>

    <!-- Honeypot: hidden from people, filled in by many bots. -->
    <div class="hp" aria-hidden="true">
      <label for="website">Leave this field empty</label>
      <input id="website" name="website" tabindex="-1" autocomplete="off">
    </div>

    <button type="submit">Send message</button>

    <small>Powered by <a rel="nofollow" href="https://un-static.com/">Un-static Forms</a></small>
  </form>
</body>
</html>

The website field is a honeypot, as described under spam protection. It only works once you set its name in step 5. If you skip that step, delete the field.

We kindly ask you to keep the Powered by link (or something similar) to support us if you don’t have a paid subscription.

Jekyll sites

If your GitHub Pages site uses Jekyll, put contact.html in the root of your site source, next to index.md or index.html. Keep only the <form> element and the <style> block, start the file with front matter, and Jekyll wraps the form in your theme’s layout. Browsers apply a <style> element inside the page body, but valid HTML keeps it in the head, so you can move the CSS into your site stylesheet or _includes/head-custom.html instead (the head hook in GitHub Pages supported themes such as Cayman or Primer):

---
layout: page
title: Contact
permalink: /contact/
---

<form class="contact-form" method="post"
      action="https://forms.un-static.com/forms/YOUR_ENDPOINT_REFERENCE">
  ...
</form>

Use a layout your theme provides. page exists in the default minima theme; other themes may call it default. The permalink line serves the page at /contact/ instead of /contact.html.

To show the same form on several pages, save the form as _includes/contact-form.html and place it with:

{% include contact-form.html %}

Do not add a .nojekyll file to a Jekyll site. It tells GitHub Pages to skip the Jekyll build, so your layouts and includes stop working. It is only for plain HTML sites that do not use Jekyll at all.

Spam protection

A form on a public page gets found by bots. Every Un-static form has a spam-protection provider: Google reCAPTCHA, Cloudflare Turnstile, hCaptcha or Off. A new endpoint starts on reCAPTCHA through our own protection page, so you do not need to add any captcha code to contact.html. Once the form is linked to an account (free), you change the provider per form under Security Settings, and protecting your form with Cloudflare Turnstile walks through switching.

On the same settings page, Set Honeypot Field takes the name of a hidden field, website in the example above. Any submission that arrives with a value in that field is marked as spam and not sent to you. Next to that, submissions that contain phrases on our spam list are filtered out, and repeated posts from one address are rate limited. None of this is a paid feature.

Let us know if you run into any issues!