👋 Need help migrating your website? Our Migration Team is here to help — learn more here!

Editing Content with Hugo Shortcodes: Built-in and Custom Shortcode Support

By CloudCannon · 2 Nov 2022
Editing Content with Hugo Shortcodes: Built-in and Custom Shortcode Support

You asked for it. We’ve done it. CloudCannon is the first CMS with full support and full integration for built-in and custom Hugo shortcodes — in our Visual, Content, and Source Editors. That’s a pretty big claim! What do we mean by this? Let’s take a look.

What are shortcodes?

Hugo uses shortcodes — code snippets in content files — to get around the limitations of Markdown, while keeping the simplicity and ease of Markdown’s syntax. Shortcodes let developers consolidate templating into small, reusable snippets that can be embedded directly inside Markdown content.

Hugo ships with a set of predefined shortcodes, which we’ve integrated and configured for immediate use in CloudCannon’s Visual and Content Editors.

How to use Hugo’s built-in shortcodes in CloudCannon

When you and your team members are working in CloudCannon’s Content Editor or Visual Editor, which provide two different WYSIWYG interfaces for Markdown content, you’ll be able to add a shortcode by simply clicking the ‘Snippet’ button at the top right of the editing pane. (More on Snippets later — we’ll be expanding this functionality across other SSGs in the coming weeks.)

WYSIWYG editor

From here you can select your Hugo shortcode.

Shortcode list

Within the shortcode interface itself, you’ll see all the available options to change the shortcode’s parameters.

Tweet example

This integration means that content editors and marketers will be able to create new shortcodes and edit existing shortcodes via an intuitive interface, without ever needing to work in source files.

If you’re a developer working locally, or via CloudCannon’s Source Editor view, simply call the shortcode in your Markdown content as you normally would — {{< shortcodename parameters >}} — and CloudCannon will include it in your Hugo build.

Here’s an example of how the gist shortcode looks in an example Markdown file:

## Heading text

Here's my Markdown content, with an example of the gist shortcode below.

{{< gist spf13 7896402 "img.html" >}}

The above shortcode, {{&lt; gist spf13 7896402 "img.html" &gt;}}, will embed the referenced code sample on your page.

You and your editors will now be able to see this gist shortcode, edit its parameters, or remove it via the Content Editor and Visual Editor views, where it appears as a component within the Markdown section of your page.

Configure your custom Hugo shortcodes in CloudCannon

If you’ve been using Hugo for a while, you’re likely to have built up a library of your own custom shortcodes, stored in layouts/shortcodes/. If you’re working locally or within CloudCannon’s Source Editor, you can use them immediately.

To ensure that others can use or edit custom shortcodes from CloudCannon’s Content Editor or Visual Editor, you’ll need to add to your global CloudCannon configuration file. If you’re familiar with the logic behind configuring inputs within CloudCannon, this will be a relatively straightforward process. For more details, view our documentation on editing content with custom Hugo shortcodes.

Shortcodes for everyone

By fully integrating both Hugo’s built-in shortcodes and your own custom Hugo shortcodes into CloudCannon’s intuitive Markdown editing views, CloudCannon help to surface one of Hugo’s core features for users with any level of technical ability.

We’ve always been focused on enhancing the editing experience for our users, and by integrating Hugo’s shortcodes fully into our Content Editor and Visual Editor we’re giving all our users a more efficient means of using templated content, and more control over their Hugo websites.

What’s next?

We’ve been working on this feature for some time, because it’s important to our users. Over the coming months we’ll start to reveal more of the bigger picture for our Snippets feature, which will include full support and integration for shortcode equivalents in other static site generators (like Liquid tags in Jekyll and Eleventy), as well as full MDX support.

Our goal is to build the best Git-based CMS for your whole team, no matter which SSG you’re using. We’d love to hear what you think about our shortcode integration for your Hugo sites, and which features are still on your wishlist.

As always, feel free to reach out to our dev team in support with any questions or comments!

Launch your website today

Give your content team full autonomy on your developer-approved tech stack with CloudCannon.

Get started free!

You might also like: