Hugo Shortcodes Library
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Div

A Hugo shortcode to wrap elements in a div and apply specific classes or a style property to it. Useful as a building block.

How to use

# file.md

Shortcode

# div.html
# new_tab_link.html

<div
{{- if .IsNamedParams -}}
    {{ if .Get `class` }} class="{{ .Get `class` }}"{{ end }}
    {{ if .Get `style` }} style="{{ .Get `style` }}"{{ end }}
{{- else -}}
    {{ if .Get 0 }} class="{{ .Get 0 }}"{{ end }}
{{- end -}}>
    {{ .Inner | markdownify }}
</div>

Sample

💁

Note: according to original author Jim Frenette:

style parameter: since the semicolon declaration separator ; is not permitted, only one declaration allowed

markdown
markdown
markdown


Source