Hugo testimonials shortcode

A Hugo testimonials shortcode is one template file in layouts/_shortcodes that outputs a div and Vouchjar's embed script, which you then call from any Markdown page. Because shortcode output skips Goldmark's raw HTML filter, you don't need to switch on unsafe mode, and testimonials you approve go live without a rebuild.

Layout
Theme
Style
Embed code
<div data-vouchjar="your-wall" data-layout="carousel" data-theme="auto"></div>
<script src="https://vouchjar.com/embed.js" async></script>

Example quotes. Want to try the collection form as well? Use the homepage demo.

What you’re adding

Vouchjar has two parts. The collection link is a page your customers open to write a few lines, pick a star rating and add a photo if they like. Nothing goes public until you approve it. The embed is a <div> and a <script> tag that render your approved testimonials as a carousel, a grid or a single quote.

A Hugo site only changes when you rebuild it. The widget fetches testimonials in the browser, so approving a new one doesn’t need a build or a deploy.

Add it to Hugo in five steps

1. Create a free wall

Sign up with your email. You don’t need a password or a card. The free plan covers one wall and five approved testimonials. Your wall’s ID is in the embed code on the dashboard.

2. Collect and approve testimonials

Send the collection link to a few customers. Already have praise on X or LinkedIn? Paste the post into Import, then check the name and text Vouchjar reads out of it. Tick Show on wall for the ones you want on the site.

3. Create the shortcode file

Save this as layouts/_shortcodes/vouchjar.html:

{{- $wall := .Get "wall" -}}
{{- if not $wall -}}
  {{- errorf "The %q shortcode needs a wall parameter: see %s" .Name .Position -}}
{{- end -}}
<div data-vouchjar="{{ $wall }}"
  {{- with .Get "layout" }} data-layout="{{ . }}"{{ end }}
  {{- with .Get "theme" }} data-theme="{{ . }}"{{ end }}></div>
<script src="https://vouchjar.com/embed.js" async></script>

The errorf line stops the build with the file and line number if you forget the wall ID, which beats an empty space on the live site. layout and theme are optional, and Hugo’s template engine escapes each value inside the attribute.

On Hugo older than 0.146, use layouts/shortcodes/vouchjar.html instead. Newer versions map the old folder to the new one, but the Hugo docs recommend renaming it.

4. Call it from your Markdown

In any content file, add:

{{< vouchjar wall="your-wall" layout="carousel" >}}

Leave out layout for the grid, or use layout="single" for one quote. Add theme="dark" on a dark site, or theme="auto" to follow the visitor’s system setting.

5. Preview and deploy

Run hugo server and open the page. The widget API accepts requests from any origin, so the wall loads on localhost too. Then build and deploy the way you normally do.

Why a shortcode and not raw HTML

Since Hugo 0.60, Goldmark has been the default Markdown renderer, and with default settings it strips any HTML you type into Markdown. You can turn that off site-wide:

[markup.goldmark.renderer]
  unsafe = true

That’s fine if you’re the only person writing content. If other people write posts too, it also lets them put any script into any page. The shortcode keeps the setting off and limits the HTML to one template file you control.

Loading the script once per page

Calling the shortcode twice on a page prints the script twice. That does no harm, since the second copy sees the widget is loaded and only rescans the page. If you’d rather keep scripts in your base template, delete the last line of the shortcode file and add this to layouts/baseof.html (layouts/_default/baseof.html on older versions), just before </body>:

{{ if .HasShortcode "vouchjar" }}
  <script src="https://vouchjar.com/embed.js" async></script>
{{ end }}

A data file or a widget?

Hugo can render testimonials from a data file such as data/testimonials.yaml with a range loop in a partial. Compared side by side:

Data file and partialVouchjar shortcode
StylingFull control in your templatesNeutral cards, light or dark
In the built HTMLYesNo, loads in the browser
Getting testimonials inYou add each one to the YAMLCustomers submit through a link, or you paste from X/LinkedIn
Adding a new oneEdit, rebuild, deployApprove in the dashboard, live within a minute
CostFreeFree for 5 testimonials, then $8/month

A data file is the better fit for a fixed handful of quotes you want in the static HTML. If the hard part is collecting new ones, the link and the shortcode do that work. Building with Astro instead? See the Astro testimonials guide.

FAQ

Why do I see "raw HTML omitted" instead of my testimonials?
You pasted the div and script straight into Markdown. Hugo's Goldmark renderer drops raw HTML unless markup.goldmark.renderer.unsafe is true, and it leaves that comment in its place. Use the shortcode instead and leave the setting off.
Should I call it with {{< >}} or {{% %}}?
Use {{< >}}. With that notation Hugo merges the shortcode's output after Markdown rendering, so the HTML arrives untouched. The {{% %}} notation sends the output through the Markdown renderer, where it's treated like raw HTML again.
Do I need to rebuild the site when I approve a testimonial?
No. Hugo only writes the div and script into the page. The testimonials load in the visitor's browser, and a newly approved one appears within about a minute.
Does it work with my theme?
Yes. Files in your site's own layouts folder sit alongside the theme's, so the shortcode works with any theme and survives theme updates. If the theme already has a shortcode called vouchjar, yours takes precedence.
Can I use the shortcode in a template instead of a content file?
No, Hugo shortcodes only run in content files. In a template, paste the div and script directly, or move them into a partial and call that.
Collect your first testimonial free

Free for 5 testimonials. No card. Pro is $8/month.

Short version: Hugo install steps in the docs.

Updated October 16, 2026