How-to · Checked November 22, 2026

How to add a contact form to a GitHub Pages site

GitHub Pages only serves static files, so it cannot receive a form. Put a plain HTML form on your page and set its action to a form endpoint. The endpoint stores the message and emails you.

It takes one commit, and works the same whether your site is hand-written HTML, Jekyll or the output of another generator.

Steps

  • Get a form endpoint. In FormTango, create a free account, add a form and copy the endpoint from the Setup tab.
  • Add the form below to a page in your repository, for example contact.html or a Jekyll include.
  • Commit and push. Wait for the Pages build to finish.
  • Open the published page and send one message.

The form

<form action="https://formtango.com/f/YOUR_FORM_ID" method="POST">

<label>Name <input type="text" name="name" required></label>

<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">

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

</form>

Is it safe in a public repository?

Yes. A form endpoint is not a secret. It can accept submissions and nothing else, so having it in public source code gives nobody access to your messages. This is the main reason to prefer it over a browser email library, which needs a key in the page.

What a public form does attract is bots. Keep the hidden _gotcha field in. FormTango also filters spam on every form automatically.

Using Jekyll

Put the form in an include such as _includes/contact.html and reference it from your page or layout. It is plain HTML, so Jekyll passes it through untouched. If you use Markdown pages, HTML blocks are allowed inside them. The Jekyll guide covers it.

After someone submits

The visitor sees a thank-you page, and you get an email with their address as the reply-to. On paid plans a hidden _redirect field sends visitors back to a page on your own site. To show a message without leaving the page, see how to submit a form with fetch. The free plan covers 1,000 submissions a month with unlimited forms. Paid plans start at $9 a month.

Common mistakes

  • Testing before the Pages build has finished, so the old page is still live.
  • Linking a script or the form action with http:// on an https:// site. Browsers block or warn about mixed content.
  • A missing name on an input.
  • Expecting a PHP file to run. GitHub Pages does not run server-side code.

Common questions

Does GitHub Pages support contact forms?
It has no form handling of its own, because it only serves static files. A form works when its action points at an outside form backend.
Can I use PHP on GitHub Pages for a contact form?
No. GitHub Pages does not run PHP or any other server-side code. Use a form endpoint in place of a PHP script.
Is there a ready example?
Yes. The [GitHub Pages guide](/guides/github-pages) has the steps and form in one place, and the [form checker](/tools/form-checker) confirms your markup is right.

Written by the FormTango team. Facts about other services were read from their own pages on November 22, 2026. Spotted something out of date? Tell us and we will fix it.

Keep reading