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
-
In GlueForms, open Forms, choose your form and copy its receiving URL. Select it above, or replace
YOUR_FORM_URLin the example. -
Create
layouts/_shortcodes/contact-form.htmlwith the form below. The HTML stays in the template rather than raw Markdown content.
<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>- Create
content/contact.mdand call the shortcode as shown. Your theme’s page template must render.Contentto 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 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.