<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PostMyForm</title>
    <description>The latest articles on DEV Community by PostMyForm (@postmyform).</description>
    <link>https://dev.to/postmyform</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4048149%2Fe5573acb-b393-4f9b-a191-602cfea8bc60.jpg</url>
      <title>DEV Community: PostMyForm</title>
      <link>https://dev.to/postmyform</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/postmyform"/>
    <language>en</language>
    <item>
      <title>How to add a contact form to GitHub Pages</title>
      <dc:creator>PostMyForm</dc:creator>
      <pubDate>Sun, 26 Jul 2026 17:23:00 +0000</pubDate>
      <link>https://dev.to/postmyform/how-to-add-a-contact-form-to-github-pages-3ndc</link>
      <guid>https://dev.to/postmyform/how-to-add-a-contact-form-to-github-pages-3ndc</guid>
      <description>&lt;p&gt;GitHub Pages is ideal for publishing fast, low-maintenance static websites, but it cannot process contact-form submissions on its own.&lt;/p&gt;

&lt;p&gt;In this guide, we’ll add a working HTML contact form, connect it to a hosted form endpoint, restrict submissions to the correct GitHub Pages origin, and test the complete flow—without deploying a server or serverless function.&lt;/p&gt;

&lt;p&gt;Add a working form without a backend&lt;/p&gt;

&lt;p&gt;GitHub Pages publishes static HTML, CSS, and JavaScript. It does not provide application code that can receive and process a form submission.&lt;/p&gt;

&lt;p&gt;PostMyForm supplies the hosted form endpoint while your website remains a normal GitHub Pages site.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create the form in PostMyForm
&lt;/h2&gt;

&lt;p&gt;Sign in to PostMyForm, open Forms, and create a form.&lt;/p&gt;

&lt;p&gt;Configure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A recognizable form name.&lt;/li&gt;
&lt;li&gt;The email address that should receive notifications.&lt;/li&gt;
&lt;li&gt;The allowed origin for the GitHub Pages site.&lt;/li&gt;
&lt;li&gt;An optional success redirect URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a project site such as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://username.github.io/project-name/" rel="noopener noreferrer"&gt;https://username.github.io/project-name/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the following allowed origin:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://username.github.io" rel="noopener noreferrer"&gt;https://username.github.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project path is not part of the browser origin.&lt;/p&gt;

&lt;p&gt;When the site uses a custom domain, enter the exact origin shown in the browser, such as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.example.com" rel="noopener noreferrer"&gt;https://www.example.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Add the fields
&lt;/h2&gt;

&lt;p&gt;Add the fields required by the contact form.&lt;/p&gt;

&lt;p&gt;A typical contact form includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;li&gt;Message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mark fields as required where appropriate.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Copy the generated form
&lt;/h2&gt;

&lt;p&gt;Open the form detail page and copy the complete generated HTML.&lt;/p&gt;

&lt;p&gt;A shortened example looks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form action="https://postmyform.com/f/your-endpoint-id" method="POST"&amp;gt;
  &amp;lt;label for="name"&amp;gt;Name&amp;lt;/label&amp;gt;
  &amp;lt;input id="name" name="name" type="text" required&amp;gt;

  &amp;lt;label for="email"&amp;gt;Email&amp;lt;/label&amp;gt;
  &amp;lt;input id="email" name="email" type="email" required&amp;gt;

  &amp;lt;label for="message"&amp;gt;Message&amp;lt;/label&amp;gt;
  &amp;lt;textarea id="message" name="message" required&amp;gt;&amp;lt;/textarea&amp;gt;

  &amp;lt;button type="submit"&amp;gt;Send message&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Use the complete snippet from the dashboard. It contains the unique endpoint and anti-spam controls required by your form.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Add the form to the repository
&lt;/h2&gt;

&lt;p&gt;Paste the generated HTML into the page or template where the contact form should appear.&lt;/p&gt;

&lt;p&gt;For a simple HTML site, this may be index.html or contact.html.&lt;/p&gt;

&lt;p&gt;Commit and push the change to the publishing source configured for GitHub Pages. That source may be a repository branch or a GitHub Actions deployment workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Confirm the published URL
&lt;/h2&gt;

&lt;p&gt;Wait for the GitHub Pages deployment to finish and open the published page in a browser.&lt;/p&gt;

&lt;p&gt;Confirm that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The form is visible.&lt;/li&gt;
&lt;li&gt;The page uses HTTPS.&lt;/li&gt;
&lt;li&gt;The browser origin matches the allowed origin in PostMyForm.&lt;/li&gt;
&lt;li&gt;The form action points to the generated PostMyForm endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Send a test submission
&lt;/h2&gt;

&lt;p&gt;Submit the published form once.&lt;/p&gt;

&lt;p&gt;A clean submission should appear in the PostMyForm dashboard and trigger an email notification attempt. The submission history records the notification result.&lt;/p&gt;

&lt;p&gt;If a success redirect is configured, PostMyForm redirects the browser after processing the submission.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. You now have a working contact form
&lt;/h2&gt;

&lt;p&gt;You now have a working contact form on a static GitHub Pages site without maintaining a separate backend.&lt;/p&gt;

&lt;p&gt;Before considering the setup complete, test the form from the published HTTPS URL and confirm that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the submission appears in the PostMyForm dashboard,&lt;/li&gt;
&lt;li&gt;the notification email arrives,&lt;/li&gt;
&lt;li&gt;the configured success redirect works,&lt;/li&gt;
&lt;li&gt;and the browser origin matches the allowed origin.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For common problems and additional details, see the full troubleshooting guide:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://postmyform.com/guides/github-pages-contact-form?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=github_pages_guide" rel="noopener noreferrer"&gt;Review the complete GitHub Pages guide and troubleshooting steps&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>github</category>
      <category>githubpage</category>
      <category>html</category>
    </item>
  </channel>
</rss>
