Add a contact form to GitHub Pages

Short answer: GitHub Pages serves static files only, so a form on it has nowhere to post. Set the form's action to a Sendform endpoint and submissions arrive by email. It works for plain HTML, Jekyll and any static site generator you deploy to Pages.

GitHub's own documentation describes Pages as "a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub" (What is GitHub Pages?, GitHub Docs, checked 2026-10-20).

1. Get an endpoint

Create a free form at sendform.app and copy https://sendform.app/api/public/f/YOUR_ID. Optional: to reject posts sent from other websites, add your Pages domain (e.g. username.github.io, or your custom domain with and without www.) under Allowed domains in the form's settings in your dashboard. Leave it empty to accept posts from anywhere.

2. Add the form (plain HTML)

<form action="https://sendform.app/api/public/f/YOUR_ID" method="POST">
  <label>Email <input type="email" name="email" required></label>
  <label>Message <textarea name="message" required></textarea></label>
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
  <input type="hidden" name="_redirect" value="https://username.github.io/thanks.html">
  <button type="submit">Send</button>
</form>

Jekyll (the default Pages generator)

Save the form as _includes/contact-form.html and add {% include contact-form.html %} to any page. Put the endpoint in _config.yml (sendform_endpoint: ...) and use {{ site.sendform_endpoint }} in the include. Use {{ "/thanks/" | absolute_url }} for _redirect.

3. Push and test

Commit, wait for the Pages build, then submit from the live URL (not localhost) and check your inbox.

Spam

Sendform filters spam with rate limits and optional Cloudflare Turnstile. The hidden _gotcha honeypot field in the snippet adds bot protection. Spam never counts toward your quota.

Troubleshooting

  • 405 or 404 on submit: the action still points at your own site. It must point at the Sendform endpoint.
  • Nothing arrives: check the ID, method="POST" and spam folder.
  • Redirect ignored: _redirect must be absolute and on the site the form is posted from, one of your allowed domains, or your saved redirect's domain.

Plans

Free: $0, 250 submissions a month. Pro: $5/mo or $48/yr for 5,000 with autoresponder, uploads, webhooks and API.