One minute
Hugo Shortcodes: Adding Space
I often found myself wanting to add empty spaces in my text. However the thought of having my text littered with a series of
blocks was repulsive.
Given that most of the content I write is in markdown, and is rendered via Hugo in most cases - both personal & work, it made sense to develop a simple system which works with any hugo site.
Here’s a simple shortcode that one can add to their static site, and inject n
number of spaces, in a clean fashion.
{{ range $_, $__ := ( .Get 0 | seq) }} {{ end }} | |
<!-- For detailed usage refer to: https://www.rajat404.com/blog/hugo-shortcode-space --> |
Save this as ./layouts/partials/space.html
in your hugo repository.
Now you can add 10 spaces by adding {{< space 10 >}}
in your markdown file.
Example
would be rendered as:
and would appear as:
“As that I can see no way out but through”
– Robert Frost
Bonus
Adding {{< space 1 >}}
in a new line, will add an empty line. No more <br>
tags!
and would appear as:
Text above
Text below