DEV Community

Chris Connelly
Chris Connelly

Posted on

Creating custom shortcodes in hugo

layouts/shortcodes/placehold.html

{{ $width := .Get 0 }}
{{ $height := .Get 1 }}
<img src="https://placehold.it/{{$width}}x{{$height}}" alt="Placehold image"/>
Enter fullscreen mode Exit fullscreen mode

We can now call

{{placehold 250 250}}
Enter fullscreen mode Exit fullscreen mode

we end up with

Alt Text

have you built any cool custom shortcodes?

Top comments (0)