Skip to content
Wrenform

Contact forms / Hugo

Contact form for Hugo without a server

A Hugo partial that emails you every submission, with the form ID kept in your site config.

Why Hugo needs a form backend

Hugo builds static files and has no server, so a contact form needs an outside service to receive it. Many themes ship a form that expects one, often with a placeholder action that does nothing.

Point that form at Wrenform. Keep the form ID in hugo.toml, render the form from a partial, and every submission is stored, filtered for spam and emailed to you. No JavaScript is needed.

The snippet

Replace YOUR_FORM_ID with the ID of your form.

{{/* layouts/partials/contact-form.html
     In hugo.toml:  [params]  wrenformId = "YOUR_FORM_ID" */}}
<form action="https://wrenform.com/f/{{ site.Params.wrenformId }}" method="POST">
  <input type="text" name="name" required>
  <input type="email" name="email" required>
  <textarea name="message" required></textarea>
  <input type="text" name="_honey" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
</form>

Steps

  1. Create a form (free) and copy its form ID.
  2. Add wrenformId under [params] in hugo.toml.
  3. Save the partial and call it from a template, or wrap it in a shortcode to use it in Markdown content.
  4. Run hugo, deploy, and add your site to Allowed origins.

Spam handling

Spam filtering is on for every form, with no CAPTCHA: a hidden honeypot field, a timing check, rate limits per visitor, and a content score for links, keywords and gibberish. Spam goes to a separate tab and is never emailed. See how spam filtering works.

Hugo can build your thank-you URL for you: a hidden _redirect field with {{ "thanks/" | absURL }} sends visitors to your own page after sending.

Deployment notes

  • Netlify. Deploy as usual. Netlify only processes forms that carry its own netlify or data-netlify attribute, so it leaves this form alone and the browser posts it to Wrenform. Add your netlify.app address and your custom domain to Allowed origins.
  • Vercel. Nothing to configure. The Hugo build stays static; you don't need a serverless function for the form. Add your production domain to Allowed origins. Preview deployments get their own addresses, so leave the list empty while you test them, or add each one.
  • Cloudflare Pages. No Pages Function needed. Add your pages.dev address and your custom domain to Allowed origins. If you set a Content-Security-Policy header, add form-action https://wrenform.com.
  • GitHub Pages. GitHub Pages serves static files only, which is all this form needs. Add https://<user>.github.io (or your custom domain) to Allowed origins. The origin is the host only, without the repository path.

FAQ

Does a Hugo contact form need a server?
No. The visitor's browser posts the form to Wrenform. Hugo only renders the HTML.
Can I use the form inside a Markdown page?
Yes. Partials don't run in content, so wrap the partial in a shortcode and call the shortcode from the page.
My theme already has a contact form. Can I keep it?
Yes. Set its action to your Wrenform endpoint and its method to POST, check every input has a name, and add the hidden _honey field.
Does it work with hugo server?
Yes. Leave allowed origins empty while you test, or add http://localhost:1313.

Next steps