Beginner4 minUpdated Mar 27, 2026

How to Add a Contact Form to Hugo

Add a working contact form to your Hugo static site using an HTML partial. No server code required. FormsList handles all submissions.

TL;DR

To add a contact form to a Hugo site, create an HTML form partial with action set to `https://formslist.com/f/your-form-id`. Hugo generates static HTML, so a form backend service handles submissions without any server code.

By Vaibhav Jain·Published March 27, 2026

Prerequisites

  • A Hugo site
  • A FormsList account (free)
  • Basic knowledge of Hugo templates
1

Create a FormsList form endpoint

Sign up for a free FormsList account and create a new form. Copy the endpoint URL. You will use it as the action attribute in your Hugo form partial.

2

Create the contact form partial

Create a new partial template in your Hugo project. This HTML form posts directly to FormsList when submitted. Hugo partials live in the layouts/partials/ directory.

<!-- layouts/partials/contact-form.html -->
<form action="https://formslist.com/f/YOUR_FORM_HASH" method="POST" class="contact-form">
  <div class="form-group">
    <label for="name">Name</label>
    <input type="text" id="name" name="name" required />
  </div>

  <div class="form-group">
    <label for="email">Email</label>
    <input type="email" id="email" name="email" required />
  </div>

  <div class="form-group">
    <label for="message">Message</label>
    <textarea id="message" name="message" rows="5" required></textarea>
  </div>

  <!-- Optional: redirect after submission -->
  <input type="hidden" name="_redirect" value="{{ "thanks" | absURL }}" />

  <button type="submit">Send Message</button>
</form>
3

Use the partial in a page or shortcode

Include the partial in your contact page template. You can also create a Hugo shortcode so content editors can add the form to any Markdown page.

<!-- layouts/_default/contact.html -->
{{ define "main" }}
<div class="container">
  <h1>{{ .Title }}</h1>
  {{ .Content }}
  {{ partial "contact-form.html" . }}
</div>
{{ end }}

<!-- Or as a shortcode: layouts/shortcodes/contact-form.html -->
{{ partial "contact-form.html" . }}

<!-- Then use in any Markdown file: -->
<!-- {{< contact-form >}} -->

Frequently Asked Questions

Can I use Hugo variables in the form?

Yes. You can use Hugo template functions like {{ .Site.Title }} or {{ .Params.formId }} to dynamically set field values, hidden inputs, or even the form action URL from your site config.

How do I style the form in Hugo?

Add CSS classes to the form elements in the partial, then style them in your theme's stylesheet. Hugo supports Tailwind CSS, SCSS, and plain CSS through its asset pipeline.

Does this work with all Hugo hosting providers?

Yes. Since the form posts to an external FormsList endpoint, it works on Netlify, Vercel, Cloudflare Pages, GitHub Pages, or any static host. No server-side processing is needed.

Ready to collect form submissions?

200 free submissions a month and a live endpoint in 30 seconds. No server, no credit card, just point your form at it.

Sign up with emailView pricing