hugo-theme-relearn/exampleSite/content/shortcodes/include.en.md
Sören Weber 8551ee2738
shortcodes: revamp shortcodes #260 #261
- supply named parameter if missing #260
- fix boolean parameter if given as string #261
- revise documentation
2022-06-05 19:31:59 +02:00

47 lines
1.3 KiB
Markdown

+++
description = "Displays content from other files"
title = "Include"
+++
The `include` shortcode includes other files from your project inside of the current page.
## Usage
While the examples are using named parameter you are free to use positional aswell.
{{< tabs groupId="shortcode-parameter">}}
{{% tab name="named" %}}
````go
{{%/* include file="shortcodes/INCLUDE_ME.md" */%}}
````
{{% /tab %}}
{{% tab name="positional" %}}
````go
{{%/* include "shortcodes/INCLUDE_ME.md" */%}}
````
{{% /tab %}}
{{< /tabs >}}
The included files can even contain Markdown and will be taken into account when generating the table of contents.
### Parameter
| Name | Position | Default | Notes |
|:---------------------|:---------|:-----------------|:------------|
| **file** | 1 | _&lt;empty&gt;_ | The path to the file to be included. Path resolution adheres to [Hugo's build-in `readFile` function](https://gohugo.io/functions/readfile/) |
| **showfirstheading** | 2 | `true` | When `false` and the included file contains headings, the first heading will be hidden. This comes in handy, eg. if you include otherwise standalone Markdown files. |
## Examples
### Arbitray Content
````go
{{%/* include "shortcodes/INCLUDE_ME.md" */%}}
````
{{% include "shortcodes/INCLUDE_ME.md" %}}