How-To Guide6 min readLast updated: 2026-09-13

Form Submission Not Working on GitHub Pages? Here’s the Fix

Why contact forms silently fail on GitHub Pages (405 errors, no email received) and how to add a working form backend in under two minutes.

Direct Answer

Why is my form submission not working on GitHub Pages?

GitHub Pages serves static files only, so form submissions fail with a 405 (or nothing happens at all). Fix: point your form action at a Form2Lead endpoint, add your `*.github.io` origin to Allowed Domains, and submissions arrive by email.

Verified product capabilityRead documentation →

What Actually Happens

GitHub Pages has no server runtime. A form POST to your Pages URL returns 405 Method Not Allowed (or the raw page HTML if a static form handler intercepts it). No email is sent because nothing processes the request.

Why GitHub Pages Can’t Process Forms (Static Hosting Only)

Pages is a static file server behind a CDN: it exists to serve HTML, CSS, and JS over GET requests, and it deliberately refuses POST bodies because there is no application on the other side to receive them. There is no PHP, no Node, no serverless function, and the whitelisted Jekyll plugin list contains no form handler either. Static site generators can build the form’s markup at deploy time — but the submit itself needs a server somewhere, which is exactly what a form backend provides.

The Two-Minute Fix

Create a form in Form2Lead, copy the endpoint URL, and set it as your form action. Keep method POST — no JavaScript required.

<form action="https://form2lead.com/api/v1/f/YOUR_FORM_ID" 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>
  <button type="submit">Send</button>
</form>

Allow Your Pages Origin

Add `yourusername.github.io` (plus your custom domain if you use one) to the form’s Allowed Domains in Form2Lead so only your site can submit.

Testing Your Form Action from the Browser Console

You can verify the endpoint end-to-end without waiting for a real visitor. Open your live Pages site, paste this into the browser console (DevTools → Console), and run it — it posts the form’s fields to your endpoint as an AJAX submission. A 200 response with JSON means the pipeline works; a CORS error means your `*.github.io` origin is missing from Allowed Domains; a 405 means the action URL still points at Pages itself.

const form = document.querySelector('form');
const res = await fetch('https://form2lead.com/api/v1/f/YOUR_FORM_ID', {
  method: 'POST',
  body: new FormData(form),
  headers: { 'Accept': 'application/json' },
});
console.log(res.status, await res.json());

Forms Inside Jekyll Layouts on GitHub Pages

Jekyll passes raw HTML through untouched, so the fix works inside layouts, includes, and collections — put the form markup in `_includes/contact-form.html` and drop `{% raw %}{% include contact-form.html %}{% endraw %}` wherever it belongs. Two Jekyll-specific gotchas: avoid form plugins (Pages disables most third-party plugins, so plugin-based forms break on deploy), and make sure your theme’s layout does not ship its own form action pointing at a placeholder URL — that is a common source of silent 404s.

<!-- _includes/contact-form.html -->
<form action="https://form2lead.com/api/v1/f/YOUR_FORM_ID" 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 !important" tabindex="-1" autocomplete="off" />
  <button type="submit">Send</button>
</form>

How-To Q&A

Direct Answer

My Jekyll site on Pages uses a form plugin — why does it fail?

GitHub Pages disables custom plugins. Replace plugin-based forms with a plain HTML form pointed at Form2Lead.

Direct Answer

Why does my contact form 404 on GitHub Pages?

A 404 usually means the form’s action attribute points at a path that does not exist on your site — a leftover `/send.php`, `/thanks`, or a placeholder URL from a theme. A POST to a real Pages URL gives a 405 instead, because Pages only serves GET. Either way the fix is the same: set the action to your Form2Lead endpoint URL.

Direct Answer

Can GitHub Pages send form submissions to email?

Not by itself — Pages is static hosting with no mail server and no code execution. Point the form at a Form2Lead endpoint and Form2Lead sends an instant email notification for every submission, with the full record stored in your dashboard as a backup.

Direct Answer

Do I need JavaScript for a working form on GitHub Pages?

No. A plain HTML form with method="POST" pointed at your Form2Lead endpoint works with JavaScript disabled. The fetch() approach is optional — use it only when you want to stay on the same page and handle the JSON response yourself, in which case send an Accept: application/json header.