Chef docs uses shortcodes to maintain text that appears in more than one location and must be consistent in every location.
Shortcode files are written in Markdown or HTML and are stored in the layouts/shortcodes directory in the chef-web-docs repo. Most shortcodes are written in Markdown but some are in HTML.
There are two types of shortcodes, Markdown and HTML. The type of shortcode determines how it is added to a page and how Hugo processes the text when it renders the page into HTML.
Note
To include a Markdown shortcode in a page, wrap the name of the shortcode file, without the file type suffix, in between double curly braces and percent characters, {{% SHORTCODE %}}. For example, if you wanted to add the chef.md shortcode to a page, add the following text to the Markdown page:
{{% chef %}}
To include an HTML shortcode in a page, wrap the name of the shortcode file, without the file type suffix, in between double curly braces and angle brackets, {{< SHORTCODE >}}. For example, add the following text to a page if you wanted to add the chef_automate_mark.html shortcode:
{{< chef_automate_mark >}}
Some shortcodes accept positioned or named parameters. For example, the example_fqdn shortcode requires a hostname, which is added like this: {{< example_fqdn "HOSTNAME" >}}, and produces the following output: HOSTNAME.example.com.
The Fontawesome Shortcode accepts named parameters. For example, it accepts a class value which is added like this: {{< fontawesome class="fas fa-ellipsis-h" >}}
See the Fontawesome Shortcode section for more examples.
We have some shortcodes that nest around Markdown content that is included in the text of a page. Those shortcodes are all written in HTML. Note the slash / before the name of the closing shortcode.
{{< shortcode_name >}}
Some Markdown text.
{{< /shortcode_name >}}
See the Notes and Warnings and the Foundation Tabs for examples of nested shortcodes.
In general, notes, warnings, and admonitions are not the best way to present important information. Before using them ask yourself how important the information is. If you want the information to be returned in a search result, then it is better for the information to have its own topic or section heading. Notes and warnings have a different color than the surrounding text so they can be easily spotted within a doc. If notes and warnings must be used, the approach for using them is as follows.
Notes and warnings are generated by bracketing the text of the note or warning in note, warning, or danger shortcodes.
{{< note >}}
This is a note.
{{< /note >}}
What a note looks like after it’s built:
Note
Use sparingly so that when the user sees a warning it registers appropriately:
{{< warning >}}
This is a warning.
{{< /warning >}}
What a warning looks like after it’s built:
Warning
Danger should be used rarely and only when there are serious consequences for the user:
{{< danger >}}
This is a danger block.
{{< /danger >}}
This is what a danger block looks like after it’s built:
Danger
There are four shortcodes that can be combined together to create a container that will allow the user to click on a tab to reveal content in a matching panel. For example, you may want to display matching Ruby and YAML code blocks. You can create two tabs, one titled Ruby and the other YAML, and the user could click on one tab to show the Ruby code block and another tab to show the YAML code block. See the example below.
The four shortcodes are:
foundation_tabsfoundation_tabfoundation_tabs_panelsfoundation_tabs_panelThese shortcodes use the Zurb Foundation Tabs component.
The container consists of two parts, the tabs and the panels.
Each tab is created with a foundation_tab shortcode. Use as many foundation_tab shortcodes as you need to display the number of code blocks or text blocks that you want the user to be able click on and reveal.
All foundation_tab shortcodes must be contained within opening and closing foundation_tabs shortcodes.
For example:
{{< foundation_tabs tabs-id="ruby-python-panel" >}}
{{< foundation_tab active="true" panel-link="ruby-panel" tab-text="Ruby" >}}
{{< foundation_tab panel-link="python-panel" tab-text="Python" >}}
{{< /foundation_tabs >}}
The foundation_tabs shortcode has one parameter:
tabs-idtabs-id value in the foundation_tabs_panels shortcode, but otherwise it must be unique on the page.The foundation_tab shortcode has three parameters:
activeUse active="true" to highlight the tab that user will see when they first load the page. Only add this value to one tab. The matching foundation_tabs_panel should also have active="true" in its parameters.
panel-linkpanel-id value in the matching foundation_tabs_panel shortcode.tab-textEach tab has a matching panel which is created with foundation_tabs_panel shortcodes. The Markdown text that is displayed in each panel must be contained in opening and closing foundation_tabs_panel shortcodes.
All foundation_tab_panel shortcodes must contained within opening and closing foundation_tabs_panels shortcodes.
For example:
{{< foundation_tabs_panels tabs-id="ruby-python-panel" >}}
{{< foundation_tabs_panel active="true" panel-id="ruby-panel" >}}
```ruby
puts 'Hello, world!'
```
{{< /foundation_tabs_panel >}}
{{< foundation_tabs_panel panel-id="python-panel" >}}
```python
print('Hello, world!')
```
{{< /foundation_tabs_panel >}}
{{< /foundation_tabs_panels >}}
The foundation_tabs_panels shortcode has one parameter:
tabs-idtabs-id value in the foundation_tabs shortcode, but otherwise it must be unique on the page.The foundation_tabs_panel shortcode has two parameters:
activeactive="true" to indicate which panel the user will see when they first load the page. This value should also be added to the panels matching tab. Only add this value to one panel.panel-idpanel-link value in the matching foundation_tab shortcode that will link to this panel. This value must be unique on the page.Below is an example of a container that shows three code blocks in three languages. You can copy and paste the code below into a page to get started. Note that the tabs-id and panel-id/panel-link values must be unique on the page.
puts 'Hello, world!'
print('Hello, world!')
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
{{< foundation_tabs tabs-id="ruby-python-go-panel" >}}
{{< foundation_tab active="true" panel-link="ruby-panel" tab-text="Ruby">}}
{{< foundation_tab panel-link="python-panel" tab-text="Python" >}}
{{< foundation_tab panel-link="golang-panel" tab-text="Go" >}}
{{< /foundation_tabs >}}
{{< foundation_tabs_panels tabs-id="ruby-python-go-panel" >}}
{{< foundation_tabs_panel active="true" panel-id="ruby-panel" >}}
```ruby
puts 'Hello, world!'
```
{{< /foundation_tabs_panel >}}
{{< foundation_tabs_panel panel-id="python-panel" >}}
```python
print('Hello, world!')
```
{{< /foundation_tabs_panel >}}
{{< foundation_tabs_panel panel-id="golang-panel" >}}
```go
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
```
{{< /foundation_tabs_panel >}}
{{< /foundation_tabs_panels >}}
The Fontawesome shortcode will display any free Font Awesome icon in a page.
It accepts the following parameters:
background-colorborderborder-radiusclasscolorfont-sizemarginpaddingThe only required parameter is class, which is the same as the class name of the icon.
The following shortcode examples will display these icons:
{{< fontawesome class="fas fa-ellipsis-h" >}}
{{< fontawesome class="fas fa-anchor" font-size="3rem" border="2px dashed" padding="1px" border-radius="5px" >}}
{{< fontawesome class="fas fa-archive" color="#cc814b" margin="0 0 0 12px">}}
{{< fontawesome class="far fa-address-book" background-color="DarkBlue" color="rgb(168, 218, 220)" >}}
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/style_reuse/