---
title: "Connect Hugo forms to email"
canonical: "https://glueforms.com/docs/connect-hugo"
language: "en"
description: "Add a Hugo contact form with a custom shortcode and receive submissions by email through GlueForms."
---

# Connect Hugo forms to email

Add a contact form to a Hugo page with a shortcode. Hugo builds the page, and the browser sends submissions directly to GlueForms.

## Connect the form

1. In GlueForms, open [Forms](https://glueforms.com/app/forms), choose your form and copy its receiving URL. Select it above, or replace `YOUR_FORM_URL` in the example.
2. Create `layouts/_shortcodes/contact-form.html` with the form below. The HTML stays in the template rather than raw Markdown content.

```html
<form action="YOUR_FORM_URL" method="POST">
  <label>
    Name
    <input name="name" autocomplete="name">
  </label>
  <label>
    Email
    <input name="email" type="email" autocomplete="email" required>
  </label>
  <label>
    Message
    <textarea name="message" rows="4" required></textarea>
  </label>
  <button type="submit">Send message</button>
</form>
```

3. Create `content/contact.md` and call the shortcode as shown. Your theme’s page template must render `.Content` to display it.

```
---
title: "Contact us"
---

{{< contact-form >}}
```

This uses Hugo’s current `_shortcodes` directory. You do not need to enable raw HTML throughout Markdown or loosen the content security configuration. Build the site and check that the contact page contains the form.

A native submission opens the GlueForms JSON receipt in the browser. Use [JavaScript](https://glueforms.com/docs/javascript) to show a confirmation on your own page.

Publish the page and submit a message. Open it in GlueForms to check the field names, saved content and email notification.

Official documentation: [Hugo shortcode templates](https://gohugo.io/templates/shortcode/), [Hugo page Content](https://gohugo.io/methods/page/content/).
