Skip to content
FormToMail

Static sites & frameworks

How do I add a contact form to a Hugo site?

By the FormToMail team · Checked against official sources · Updated

Hugo generates static files and has no built-in form handling, so a Hugo contact form is plain HTML whose `action` points to a form endpoint (or to Netlify Forms if you host on Netlify). Put the form in a partial or shortcode so you can drop it into any page or layout.

Where to put the form in Hugo
PlaceUse it when
ShortcodeYou want {{< contact >}} inside Markdown content
PartialThe form is part of a layout (footer, contact page template)
Custom layout for the contact pageOne dedicated page with its own design

Shortcode file (contact.html)

Save as a shortcode named contact in your templates folder (Hugo's docs show the folder for your version), then write {{< contact >}} in content/contact.md.

html
<form action="https://getformtomail.com/f/YOUR_FORM_ID" method="POST">
  <input name="name" required>
  <input name="email" type="email" required>
  <textarea name="message" required></textarea>
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
</form>

Hosting notes

  • On Netlify you can also use Netlify Forms; on GitHub Pages or Cloudflare Pages you need an endpoint.
  • The endpoint URL is public by design; spam checks run on the endpoint.

Quick answers

How do I add a contact form to a hugo site?

Use a shortcode or partial with a form endpoint as the action.

Does Hugo support Formspree?

Hugo doesn't need to: any form endpoint works because the form is plain HTML.

Can I add a Hugo form without JavaScript?

Yes, the HTML form above posts directly and redirects to a thank-you page.

What to do next

Create an endpoint for your Hugo shortcode.

Get your form endpoint

Sources

Checked: . Prices, limits and features of other services change: confirm current values at the official links above. Product names belong to their owners; we are not affiliated with them.