Static website with HUGO - Shortcodes

How to display a GitLab snippet

By default, HUGO provides a gist shortcode to include GitHub gists in a post. But there is no shortcode for GitLab snippets. Let’s create it. For more details I wish you to have a look to this post.

Create mygitlabset.html file

C:\hugo\sites\blog\layouts\shortcodes>dir
04/06/2018  15:21    <DIR>          .
04/06/2018  15:21    <DIR>          ..
04/06/2018  15:21               0 mygitlabset.html

Add content

<script src="{{.Get "src"}}"></script>

Use this shortcode in md files

cms hugo gitlab shortcode

Displaying example

Here is a GitLab snippet (GitHub gist like) from the graphql post.

comments powered by Disqus