GitHub Pages

A contact form on GitHub Pages.

GitHub Pages only serves the files in the repo. It will not run PHP, and it will not accept a form POST. The form has to post somewhere else. That is the form backend.

The HTML

<form action="https://smote.sh/f/FORM_ID" method="POST">
  <input name="email" type="email" required>
  <textarea name="message" required></textarea>
  <input type="hidden" name="_redirect" value="https://yoursite.com/thanks">
  <button>Send</button>
</form>

Where the file goes

Plain HTML: put the form in index.html or contact.html. Jekyll on Pages: drop it in _includes/contact.html and {% include contact.html %} from a page. No plugin. Pages’ plugin safelist does not matter because nothing runs on GitHub after deploy.

You do not need a GitHub Action for this

An Action that emails you is another backend you have to keep. smote is one action URL. Create it in the dashboard, replace FORM_ID, push. Works on username.github.io and project pages.

Get an action URL Docs

Also: Hugo · Astro · Jekyll · Cloudflare Pages · Any static site