Add a contact form to GitHub Pages and get replies by email
GitHub Pages only serves static files, so it can't process a contact form itself. Point the form at FormThunder instead: it receives the POST, stores it and emails you. The access key can sit in your public repo, because it only sends to addresses you've verified. Set a redirect that includes your repo's path, and you've got a working form.
Updated
The GitHub Pages code
<form action="https://formthunder.com/submit" method="POST">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">
<input type="hidden" name="subject" value="New message from the website">
<input type="hidden" name="redirect" value="https://YOUR_USER.github.io/YOUR_REPO/thanks.html">
<input type="checkbox" name="botcheck" style="display:none" tabindex="-1" autocomplete="off">
<label for="name">Name</label>
<input id="name" name="name" required>
<label for="email">Email</label>
<input id="email" name="email" type="email" required>
<label for="message">Message</label>
<textarea id="message" name="message" rows="5" required></textarea>
<button type="submit">Send</button>
</form>- name: Build
run: npm ci && npm run build
env:
VITE_FORMTHUNDER_KEY: YOUR_ACCESS_KEYReplace YOUR_ACCESS_KEY with your free key. It's public by design, so it's safe in client code.
Notes for GitHub Pages
- Project sites live at
user.github.io/repo/, so a redirect to/thanks.htmlwould miss the repo folder. User sites and custom domains don't have this problem. - You don't need a GitHub Actions secret for the key, since it's public by design. A secret would only hide something that ends up in your HTML anyway.
- If you turn on domain restriction on Pro, add
yourname.github.io. It matches project sites on that host too. - Without a
.nojekyllfile, GitHub Pages runs Jekyll over your files. That's harmless for this form, but it does ignore folders starting with an underscore.
Or have your AI add it
Connect the MCP server, then ask. The agent creates the form and writes the code for you, and it can send a real test when it's done.
Add a FormThunder contact form to this GitHub Pages site that emails hello@example.com. Send a test when you're done.Questions
Can GitHub Pages process forms?
No. It's static hosting, so a POST to your own site fails. The form has to post to another service.
Is it safe to commit the access key to a public repo?
Yes. It's designed to be public: it can only send to verified recipients, and you can restrict it by domain on Pro.
Get your GitHub Pages form sending
The free plan covers 250 submissions a month, with MCP, the CLI and the brand kit included.