2021-08-25 11:33:29 +00:00
+++
2022-06-05 17:31:59 +00:00
description = "Displays content from other files"
2021-08-25 11:33:29 +00:00
title = "Include"
+++
2021-08-23 20:16:08 +00:00
2022-06-05 17:31:59 +00:00
The `include` shortcode includes other files from your project inside of the current page.
2021-08-23 20:16:08 +00:00
## Usage
2022-06-05 17:31:59 +00:00
While the examples are using named parameter you are free to use positional aswell.
{{< tabs groupId = "shortcode-parameter" > }}
{{% tab name="named" %}}
2021-08-23 21:32:34 +00:00
````go
2022-06-05 17:31:59 +00:00
{{%/* include file="shortcodes/INCLUDE_ME.md" */%}}
2021-08-23 20:16:08 +00:00
````
2022-06-05 17:31:59 +00:00
{{% /tab %}}
{{% tab name="positional" %}}
2021-08-28 08:08:10 +00:00
2022-06-05 17:31:59 +00:00
````go
{{%/* include "shortcodes/INCLUDE_ME.md" */%}}
````
2021-08-28 08:08:10 +00:00
2022-06-05 17:31:59 +00:00
{{% /tab %}}
{{< / tabs > }}
2021-08-23 20:16:08 +00:00
2022-06-05 17:31:59 +00:00
The included files can even contain Markdown and will be taken into account when generating the table of contents.
2021-08-23 20:16:08 +00:00
2022-06-05 17:31:59 +00:00
### Parameter
| Name | Position | Default | Notes |
|:---------------------|:---------|:-----------------|:------------|
| **file** | 1 | _<empty>_ | 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
2021-08-23 20:16:08 +00:00
2021-08-23 21:32:34 +00:00
````go
2021-08-23 20:16:08 +00:00
{{%/* include "shortcodes/INCLUDE_ME.md" */%}}
````
2022-06-05 17:31:59 +00:00
{{% include "shortcodes/INCLUDE_ME.md" %}}