2021-05-23 20:42:47 +00:00
---
title: Shortcodes
date: 2021-05-23T20:00:00+01:00
authors:
- john-doe
tags:
- Documentation
- Shortcodes
geekblogToC: 1
---
<!-- markdownlint - disable MD024 -->
The theme bundles some handy shortcodes that tries to cover common situations.
<!-- more -->
{{< toc > }}
## Buttons
Buttons are styled links that can lead to local page or external link.
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
2021-05-24 13:22:22 +00:00
{{< /* button relref="/" [class="...", size="large|regular"] */>}}Get Home{{</* /button */>}}
2021-05-24 11:41:38 +00:00
{{< /* button href="https://github.com/thegeeklab/hugo-geekblog" */>}}Contribute{{</* /button */>}}
2021-05-23 20:42:47 +00:00
```
### Example
{{< button relref = "/" > }}Get Home{{< / button > }}
2021-05-24 11:41:38 +00:00
{{< button href = "https://github.com/thegeeklab/hugo-geekblog" > }}Contribute{{< / button > }}
2021-05-23 20:42:47 +00:00
## Columns
The Columns shortcode can be used to organize content side-by-side (horizontally) for better readability.
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```html
{{< /* columns */>}} <!-- begin columns block -->
# Left Content
Dolor sit, sumo unique argument um no ...
< --- > <!-- magic sparator, between columns -->
# Mid Content
Dolor sit, sumo unique argument um no ...
< --- > <!-- magic sparator, between columns -->
# Right Content
Dolor sit, sumo unique argument um no ...
{{< /* /columns */>}}
```
### Example
{{< columns > }}
#### Left
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts
feud gait, quid exercise emeritus bis e. In pro quints consequent, denim fastidious
copious quo ad. Stet probates in duo.
< --- >
#### Mid Content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re.
< --- >
#### Right Content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts
feud gait, quid exercise emeritus bis e. In pro quints consequent, denim fastidious
copious quo ad. Stet probates in duo.
{{< / columns > }}
## Emojify
Emoji can be enabled in a Hugo project in a number of ways.
The [emojify ](https://gohugo.io/functions/emojify/ ) function can be called directly in templates or [Inline Shortcodes ](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes ). To enable emoji globally, set `enableEmoji` to `true` in your site's [configuration ](https://gohugo.io/getting-started/configuration/ ) and then you can type emoji shorthand codes directly in content files:
| Result | Inline | Shortcode |
| --------------------------------- | ----------------- | --------------------------------------- |
| {{< emojify " :see_no_evil: " > }} | `:see_no_evil:` | `{{</* emojify ":see_no_evil:" */>}}` |
| {{< emojify " :hear_no_evil: " > }} | `:hear_no_evil:` | `{{</* emojify ":hear_no_evil:" */>}}` |
| {{< emojify " :speak_no_evil: " > }} | `:speak_no_evil:` | `{{</* emojify ":speak_no_evil:" */>}}` |
The [Emoji cheat sheet ](http://www.emoji-cheat-sheet.com/ ) is a useful reference for emoji shorthand codes.
{{< hint info > }}
**Info**\
The above steps enable Unicode Standard emoji characters and sequences in Hugo, however the rendering of these glyphs depends on the browser and the platform. To style the emoji you can either use a third party emoji font or a font stack.
{{< / hint > }}
**Styling:**
<!-- spellchecker - disable -->
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
{{< highlight html " linenos = table" > }}
.emoji {
font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
}
{{< / highlight > }}
2021-09-23 10:01:54 +00:00
2021-05-23 20:42:47 +00:00
<!-- spellchecker - enable -->
## Expand
Expand shortcode can help to decrease clutter on screen by hiding part of text. Expand content by clicking on it.
### Example
#### Default
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* expand */>}}
## Markdown content
Dolor sit, sumo unique ...
{{< /* /expand */>}}
```
{{< expand > }}
##### Markdown content
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / expand > }}
#### With Custom Label
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* expand "Custom Label" "..." */>}}
## Markdown content
Dolor sit, sumo unique ...
{{< /* /expand */>}}
```
{{< expand " Custom Label " " . . . " > }}
##### More markdown
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts
feud gait, quid exercise emeritus bis e. In pro quints consequent, denim fastidious
copious quo ad. Stet probates in duo.
{{< / expand > }}
## Hint
Hint shortcode can be used as hint/alerts/notification block.
There are four colors to choose: `info` , `ok` , `warning` and `danger` .
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
2022-01-23 20:36:07 +00:00
{{< /* hint [info|ok|warning|danger] */>}}
2021-05-23 20:42:47 +00:00
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
2021-09-23 10:01:54 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
2021-05-23 20:42:47 +00:00
{{< /* /hint */>}}
```
### Example
{{< hint info > }}
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
{{< hint ok > }}
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
{{< hint warning > }}
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
{{< hint danger > }}
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
## Icon
Simple shortcode to include icons from SVG sprites outside of menus.
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* icon "thumbs-up" */>}}
```
### Example
| Result | Usage |
| -------------------------- | -------------------------------- |
| {{< icon " thumbs-up " > }} | `{{</* icon "thumbs-up" */>}}` |
| {{< icon " thumbs-down " > }} | `{{</* icon "thumbs-down" */>}}` |
| {{< icon " laugh " > }} | `{{</* icon "laugh" */>}}` |
| {{< icon " lemon " > }} | `{{</* icon "lemon" */>}}` |
| {{< icon " moon " > }} | `{{</* icon "moon" */>}}` |
## Tabs
Tabs let you organize content by context, for example installation instructions for each supported platform.
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* tabs "uniqueid" */>}}
{{< /* tab "macOS" */>}} # macOS Content {{</* /tab */>}}
{{< /* tab "Linux" */>}} # Linux Content {{</* /tab */>}}
{{< /* tab "Windows" */>}} # Windows Content {{</* /tab */>}}
{{< /* /tabs */>}}
```
### Example
{{< tabs " uniqueid " > }}
{{< tab " macOS " > }}
#### macOS
This is tab **macOS** content.
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad
prompts feud gait, quid exercise emeritus bis e. In pro quints consequent, denim
fastidious copious quo ad. Stet probates in duo.
{{< / tab > }}
{{< tab " Linux " > }}
#### Linux
This is tab **Linux** content.
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad
prompts feud gait, quid exercise emeritus bis e. In pro quints consequent, denim
fastidious copious quo ad. Stet probates in duo.
{{< / tab > }}
{{< tab " Windows " > }}
#### Windows
This is tab **Windows** content.
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates
investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad
prompts feud gait, quid exercise emeritus bis e. In pro quints consequent.
{{< / tab > }}
{{< / tabs > }}
2022-02-22 15:45:10 +00:00
2022-02-22 20:42:44 +00:00
## Mermaid
[Mermaid ](https://mermaidjs.github.io/ ) is library for generating SVG charts and diagrams from text.
<!-- more -->
### Example
{{< columns > }}
<!-- prettier - ignore -->
```tpl
{{< /* mermaid class="text-center"*/>}}
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
alt is sick
Bob->>Alice: Not so good :(
else is well
Bob->>Alice: Feeling fresh like a daisy
end
opt Extra response
Bob->>Alice: Thanks for asking
end
{{< /* /mermaid */>}}
```
< --- >
<!-- spellchecker - disable -->
<!-- prettier - ignore -->
{{< mermaid class = "text-center" > }}
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
alt is sick
Bob->>Alice: Not so good :(
else is well
Bob->>Alice: Feeling fresh like a daisy
end
opt Extra response
Bob->>Alice: Thanks for asking
end
{{< / mermaid > }}
<!-- spellchecker - enable -->
{{< / columns > }}
2022-02-22 15:45:10 +00:00
## KaTeX
[KaTeX ](https://katex.org/ ) shortcode let you render math typesetting in markdown document.
### Example
{{< columns > }}
```latex
{{< /* katex [display] [class="text-center"] */>}}
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{< /* /katex */>}}
```
< --- >
<!-- spellchecker - disable -->
<!-- prettier - ignore -->
{{< katex display > }}
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{< / katex > }}
<!-- spellchecker - enable -->
{{< / columns > }}
2022-02-22 20:42:44 +00:00
KaTeX can also be used inline, for example {{< katex > }}\pi(x){{< / katex > }} or used with the `display` parameter (e.g. `display: block` ):
2022-02-22 15:45:10 +00:00
<!-- spellchecker - disable -->
<!-- prettier - ignore -->
{{< katex display > }}
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
{{< / katex > }}
<!-- spellchecker - enable -->
Text continues here.