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.
2023-10-27 19:58:03 +00:00
### Usage
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
```
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-buttons sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
### Example
2023-05-03 12:00:13 +00:00
<!-- prettier - ignore - start -->
<!-- markdownlint - capture -->
<!-- markdownlint - disable -->
2021-05-23 20:42:47 +00:00
{{< button relref = "/" > }}Get Home{{< / button > }}
2021-05-24 11:41:38 +00:00
{{< button href = "https://github.com/thegeeklab/hugo-geekblog" > }}Contribute{{< / button > }}
2023-05-03 12:00:13 +00:00
<!-- markdownlint - restore -->
<!-- prettier - ignore - end -->
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.
2022-07-11 12:27:54 +00:00
### Usage
2021-09-23 10:01:54 +00:00
<!-- prettier - ignore -->
2021-05-23 20:42:47 +00:00
```html
2022-07-11 12:27:54 +00:00
{{< /* columns [size="small|regular|large"] */>}} <!-- begin columns block -->
2021-05-23 20:42:47 +00:00
# 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 */>}}
```
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-columns sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
### 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.
2023-10-27 19:58:03 +00:00
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.
2021-05-23 20:42:47 +00:00
2023-10-27 19:58:03 +00:00
### Example
| Output | Inline | Shortcode |
2021-05-23 20:42:47 +00:00
| --------------------------------- | ----------------- | --------------------------------------- |
| {{< 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:" */>}}` |
2022-06-29 19:04:12 +00:00
The [Emoji cheat sheet ](https://github.com/ikatyang/emoji-cheat-sheet ) is a useful reference for emoji shorthand codes.
2021-05-23 20:42:47 +00:00
2022-04-30 12:32:07 +00:00
{{< hint type = note > }}
2021-05-23 20:42:47 +00:00
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 > }}
2023-10-27 19:58:03 +00:00
<!-- prettier - ignore - start -->
2021-05-23 20:42:47 +00:00
<!-- spellchecker - disable -->
{{< highlight html " linenos = table" > }}
.emoji {
font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
}
{{< / highlight > }}
<!-- spellchecker - enable -->
2023-10-27 19:58:03 +00:00
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
## Expand
Expand shortcode can help to decrease clutter on screen by hiding part of text. Expand content by clicking on it.
2023-10-27 19:58:03 +00:00
### Usage
2021-05-23 20:42:47 +00:00
```tpl
{{< /* expand */>}}
2023-10-27 19:58:03 +00:00
### Markdown content
2021-05-23 20:42:47 +00:00
Dolor sit, sumo unique ...
{{< /* /expand */>}}
```
2023-10-27 19:58:03 +00:00
It is also possible to use a custom label and symbol.
2021-05-23 20:42:47 +00:00
2023-10-27 19:58:03 +00:00
<!-- prettier - ignore - start -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* expand "Custom Label" "..." */>}}
2023-10-27 19:58:03 +00:00
### More markdown
2021-05-23 20:42:47 +00:00
Dolor sit, sumo unique ...
{{< /* /expand */>}}
```
2023-10-27 19:58:03 +00:00
### Example
{{< 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 > }}
2021-05-23 20:42:47 +00:00
{{< expand " Custom Label " " . . . " > }}
2023-10-27 19:58:03 +00:00
#### More markdown
2021-05-23 20:42:47 +00:00
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.
2022-07-11 12:27:54 +00:00
### Usage
2022-04-30 12:32:07 +00:00
<!-- prettier - ignore - start -->
2021-05-23 20:42:47 +00:00
```tpl
2023-10-27 19:58:03 +00:00
{{< /* hint type=[note|tip|important|caution|warning] (icon=gblog_github) (title=GitHub) */>}}
2021-05-23 20:42:47 +00:00
**Markdown content**\
Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture.
2022-04-30 12:32:07 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
2021-05-23 20:42:47 +00:00
{{< /* /hint */>}}
```
2022-04-30 12:32:07 +00:00
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-hints sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
### Example
2022-04-30 12:32:07 +00:00
{{< hint type = note > }}
**Markdown content**\
2024-06-07 19:43:31 +00:00
Dolor sit, sumo unique `argument um no` . Gracie nominal id xiv. Romanesque acclimates investiture.
2022-04-30 12:32:07 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
{{< hint type = tip > }}
2021-05-23 20:42:47 +00:00
**Markdown content**\
2024-06-07 19:43:31 +00:00
Dolor sit, sumo unique `argument um no` . Gracie nominal id xiv. Romanesque acclimates investiture.
2021-05-23 20:42:47 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
2022-04-30 12:32:07 +00:00
{{< hint type = important > }}
2021-05-23 20:42:47 +00:00
**Markdown content**\
2024-06-07 19:43:31 +00:00
Dolor sit, sumo unique `argument um no` . Gracie nominal id xiv. Romanesque acclimates investiture.
2021-05-23 20:42:47 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
2022-04-30 12:32:07 +00:00
{{< hint type = caution > }}
2021-05-23 20:42:47 +00:00
**Markdown content**\
2024-06-07 19:43:31 +00:00
Dolor sit, sumo unique `argument um no` . Gracie nominal id xiv. Romanesque acclimates investiture.
2021-05-23 20:42:47 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
{{< / hint > }}
2022-04-30 12:32:07 +00:00
{{< hint type = warning > }}
2021-05-23 20:42:47 +00:00
**Markdown content**\
2024-06-07 19:43:31 +00:00
Dolor sit, sumo unique `argument um no` . Gracie nominal id xiv. Romanesque acclimates investiture.
2021-05-23 20:42:47 +00:00
Ornateness bland it ex enc, est yeti am bongo detract re.
2022-12-21 10:53:05 +00:00
Romanesque acclimates investiture.
2021-05-23 20:42:47 +00:00
{{< / hint > }}
2022-04-30 12:32:07 +00:00
Example with a custom icon and title:
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< hint type = note icon = gblog_github title = GitHub > }}
**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 > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
## Icon
Simple shortcode to include icons from SVG sprites outside of menus.
2023-10-27 19:58:03 +00:00
### Usage
<!-- prettier - ignore - start -->
2021-05-23 20:42:47 +00:00
```tpl
{{< /* icon "thumbs-up" */>}}
```
2023-10-27 19:58:03 +00:00
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
### Example
2023-10-27 19:58:03 +00:00
| Output | Code |
2021-05-23 20:42:47 +00:00
| -------------------------- | -------------------------------- |
| {{< 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.
2023-10-27 19:58:03 +00:00
### Usage
<!-- prettier - ignore - start -->
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 */>}}
```
2023-10-27 19:58:03 +00:00
<!-- prettier - ignore - end -->
2021-05-23 20:42:47 +00:00
### 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-07-11 12:37:17 +00:00
## Boxes
Boxes can be used to create a simple grid.
### Usage
<!-- prettier - ignore -->
```tpl
{{< /* boxes "contact" */>}}
{{< /* box size=large [title=E-Mail icon=gblog_email] */>}}mail@example.com{{</* /box */>}}
{{< /* box size=large title=Matrix icon=gblog_matrix */>}}@john:example.com{{</* /box */>}}
{{< /* box size=large title=XMPP icon=gblog_xmpp */>}}john@example.com{{</* /box */>}}
{{< /* box size=large title=Others */>}}You can also find us on the Fediverse.{{</* /box */>}}
{{< /* /boxes */>}}
```
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-boxes sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2022-07-11 12:37:17 +00:00
### Example
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
2023-05-03 12:00:13 +00:00
<!-- markdownlint - capture -->
<!-- markdownlint - disable -->
2022-07-11 12:37:17 +00:00
{{< boxes " contact " > }}
{{< box size = large title = E-Mail icon = gblog_email > }}mail@example.com{{< / box > }}
{{< box size = large title = Matrix icon = gblog_matrix > }}@john:example.com{{< / box > }}
{{< box size = large title = XMPP icon = gblog_xmpp > }}john@example.com{{< / box > }}
{{< box size = large title = Others > }}You can also find us on the Fediverse.{{< / box > }}
{{< / boxes > }}
2023-05-03 12:00:13 +00:00
<!-- markdownlint - restore -->
2022-07-11 12:37:17 +00:00
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2022-02-22 20:42:44 +00:00
## Mermaid
[Mermaid ](https://mermaidjs.github.io/ ) is library for generating SVG charts and diagrams from text.
2023-10-27 19:58:03 +00:00
### Usage
2022-02-22 20:42:44 +00:00
<!-- prettier - ignore -->
```tpl
2023-10-27 19:58:03 +00:00
{{< /* mermaid class="text-center" */>}}
2022-02-22 20:42:44 +00:00
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
2023-10-27 19:58:03 +00:00
{{< /* /mermaid */>}}
2022-02-22 20:42:44 +00:00
```
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-mermaid sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
### Example
2022-02-22 20:42:44 +00:00
<!-- 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 > }}
2023-10-27 19:58:03 +00:00
<!-- spellchecker - enable -->
2022-08-30 19:24:49 +00:00
As an alternative to shortcodes, code blocks can be used for markdown as well.
{{< columns > }}
<!-- prettier - ignore -->
````tpl
```mermaid
flowchart LR
A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
```
````
< --- >
<!-- spellchecker - disable -->
<!-- prettier - ignore -->
```mermaid
flowchart LR
A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
```
<!-- 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.
2023-10-27 19:58:03 +00:00
### Usage
2022-02-22 15:45:10 +00:00
```latex
2023-10-27 19:58:03 +00:00
{{< /* katex [display] [class="text-center"] */>}}
2022-02-22 15:45:10 +00:00
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
2023-10-27 19:58:03 +00:00
{{< /* /katex */>}}
2022-02-22 15:45:10 +00:00
```
2023-10-27 19:58:03 +00:00
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-katex sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
### Example
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 -->
2023-10-27 19:58:03 +00:00
KaTeX can be used inline, for example {{< katex > }}\pi(x){{< / katex > }} or used with the `display` parameter as above.
2022-08-31 08:15:13 +00:00
## Progress
2023-10-27 19:58:03 +00:00
### Usage
<!-- prettier - ignore -->
```tpl
{{< /* progress title=Eating value=65 icon=gblog_heart */>}}
```
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< propertylist name = shortcode-progress sort = name order = asc > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
### Example
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< progress title = Eating value = 65 icon = gblog_heart > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
## Properties
2022-08-31 08:15:13 +00:00
2023-10-27 19:58:03 +00:00
The property list shortcode creates a custom HTML description list that can be used to display properties or variables and general dependent information. The shortcode requires a data file in `data/properties/` , e.g. `data/properties/demo.yaml` .
2022-08-31 08:15:13 +00:00
### Usage
<!-- prettier - ignore - start -->
```tpl
2023-10-27 19:58:03 +00:00
{{< /* propertylist name=demo (sort=name) (order=[asc|desc]) */>}}
2022-08-31 08:15:13 +00:00
```
<!-- prettier - ignore - end -->
2023-10-27 19:58:03 +00:00
The supported attributes can be taken from the following example:
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
{{< include file = "/data/properties/demo.yaml" language = "Yaml" options = "linenos=table" > }}
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
#### Attributes
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
2023-10-27 20:31:04 +00:00
{{< propertylist name = shortcode-propertylist sort = name order = asc > }}
2023-10-27 19:58:03 +00:00
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->
2022-08-31 08:15:13 +00:00
### Example
<!-- prettier - ignore - start -->
<!-- spellchecker - disable -->
2023-10-27 19:58:03 +00:00
{{< propertylist name = demo sort = name order = asc > }}
2022-08-31 08:15:13 +00:00
<!-- spellchecker - enable -->
<!-- prettier - ignore - end -->