At a glance
- Output
- Static
- Server code
- Not possible
- Build step
- None
- Where it goes
- Any .html file
- Jekyll plugin
- Not needed
The integration
Paste this into any .html file in your GitHub Pages repo. It’s a normal form whose action is your endpoint: no build step, no JavaScript, no Jekyll plugin. On submit, the visitor lands on a branded success page, or on your own with a hidden _mtf_redirect field.
<form action="https://mtform.co/f/your-form-key" method="POST">
<label>
Name
<input name="name" autocomplete="name" required>
</label>
<label>
Email
<input type="email" name="email" autocomplete="email" required>
</label>
<label>
Message
<textarea name="message" required></textarea>
</label>
<!-- Spam trap: hidden from people, tempting to bots. Leave it empty. -->
<input
type="text"
name="_mtf_honeypot"
tabindex="-1"
autocomplete="off"
aria-hidden="true"
style="position:absolute;left:-9999px"
>
<button type="submit">Send</button>
</form>Step by step
- 1
Create the endpoint
Create a MakeTheForm form to get your public endpoint URL and inbox.
- 2
Add the form to your page
In any HTML file in your repo, set the <form> action to the endpoint and method to POST, and include the _mtf_honeypot field.
- 3
Commit and let Pages deploy
Push to the branch GitHub Pages serves. No plugin or Action is needed. It’s plain static HTML.
- 4
Verify and test
Verify your recipient email once, open the live Pages URL, and submit to confirm it reaches your inbox and email.
Common pitfalls
Hunting for a server-side option that isn’t there
There’s no PHP mailer, no serverless function, no ‘form handler’ setting on GitHub Pages. The platform runs zero server code by design. An external endpoint isn’t a compromise here; it’s the only architecture that can work.
Skipping the honeypot on a public repo
GitHub Pages sites are indexed and often open-source, so bots find the form fast. Include the hidden _mtf_honeypot input. It’s the zero-JS spam trap. Leave it empty, and never make it required or display:none.
Troubleshooting
| Symptom | What’s happening | Fix |
|---|---|---|
| 404 on submit | The action points at a repo path instead of the full endpoint URL. | Use the absolute https:// endpoint URL as the form action. GitHub Pages can’t process a relative form path. |
| no success page | The form submitted but you expected to stay on your own site. | A plain form navigates to the endpoint’s success page; set a custom redirect back to your site in settings. |
| 403 | Allowed-domains is on and your github.io or custom domain isn’t listed. | Add your Pages domain in the form’s spam settings, or leave the form public. |
Frequently asked questions
Can you add a contact form to a GitHub Pages site?
Yes. GitHub Pages can’t process forms itself, but a plain HTML form can POST to an external endpoint that can. Set the form’s action to the endpoint and you get email delivery, spam filtering, and stored submissions with no server.
How do I handle form submissions on a static site with no server?
Send them to a hosted form endpoint. The static page holds the form; the endpoint, running off your site, receives the POST, filters spam, emails you, and stores each submission. No backend code lives in your repo.
Do I need JavaScript for a GitHub Pages contact form?
No. A plain HTML form with an action and method POST works with zero JavaScript. Add a small fetch script only if you want an inline success message instead of navigating to the endpoint’s success page.
Other platforms
Keep going
Last reviewed by the MakeTheForm team.