Skip to content
Documentation

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, 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>

  1. Create content/contact.md and call the shortcode as shown. Your theme’s page template must render .Content to display it.
Markdown
---
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 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, Hugo page Content.