Skip to content
Wrenform

Docs / Frameworks

Contact form for Hugo

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

Last updated 2026-11-14View as Markdown
{{/* 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 and copy its form ID from the Setup page.
  2. Add the ID to your site config:
[params]
  wrenformId = "YOUR_FORM_ID"
  1. Save the partial as layouts/partials/contact-form.html.
  2. Call it from a template, for example layouts/_default/contact.html: {{ partial "contact-form.html" . }}.
  3. Build and deploy as usual. Then add your site's origin under Allowed origins in the form's settings.

Hugo has no server, and it doesn't need one here: the visitor's browser posts the form to Wrenform.

Use it inside Markdown content

Partials don't run inside Markdown pages. To place the form in content/contact.md, wrap the partial in a shortcode:

{{ partial "contact-form.html" . }}

Then write {{< contact-form >}} in the page where the form should appear.

Your own thank-you page

Add a hidden _redirect field with an absolute URL built by Hugo:

<input type="hidden" name="_redirect" value="{{ "thanks/" | absURL }}">

The URL must be on one of the form's allowed origins, or we ignore it. You can also set Redirect to in the form's settings instead. See redirects.

Test it

Run hugo server, open the page and send the form. Check your dashboard and inbox. While you test on localhost, leave Allowed origins empty or add http://localhost:1313.

Common problems

  • The form action ends in /f/. site.Params.wrenformId is empty. Check the parameter name and that it sits under [params].
  • _redirect is ignored. absURL uses your baseURL. On hugo server that's localhost, which isn't in your allowed origins.
  • The shortcode prints nothing. The shortcode file name must match the name you use in the page.

Next steps

Something wrong or unclear on this page? Report a problem: write to hello [at] wrenform.com with the page address (/docs/frameworks/hugo).