# 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-14. Web version: https://wrenform.com/docs/frameworks/hugo

```html
{{/* 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](/sign-in) and copy its form ID from the Setup page.
2. Add the ID to your site config:

```toml
[params]
  wrenformId = "YOUR_FORM_ID"
```

3. Save the partial as `layouts/partials/contact-form.html`.
4. Call it from a template, for example `layouts/_default/contact.html`: `{{ partial "contact-form.html" . }}`.
5. 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:

```html
{{ 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:

```html
<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](/docs/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

- [My form isn't working](/docs/troubleshooting): symptom, cause and fix.
- [Spam](/docs/spam): how the filters work.
- [Fields](/docs/fields): subjects, reply-to, lists and checkboxes.
- [HTML guide](/docs/frameworks/html): the strict Content-Security-Policy version.
