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
- Create a form (free) and copy its form ID.
- Add
wrenformIdunder[params]inhugo.toml. - Save the partial and call it from a template, or wrap it in a shortcode to use it in Markdown content.
- 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
netlifyordata-netlifyattribute, so it leaves this form alone and the browser posts it to Wrenform. Add yournetlify.appaddress 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.devaddress and your custom domain to Allowed origins. If you set a Content-Security-Policy header, addform-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?
Can I use the form inside a Markdown page?
My theme already has a contact form. Can I keep it?
Does it work with hugo server?
Next steps
- The full Hugo guide: every option, testing, and common problems.
- HTML contact form without a backend
- Contact form for Astro without a backend
- Pricing: free for 250 submissions a month.