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-22 22:03:24 +00:00
While the examples are using shortcodes with named parameter you are free to use positional aswell or also call this shortcode from your own partials.
2022-06-05 17:31:59 +00:00
2023-07-27 15:02:13 +00:00
{{< tabs groupid = "shortcode-parameter" > }}
2023-06-05 21:20:37 +00:00
{{% tab title="shortcode" %}}
2022-06-05 17:31:59 +00:00
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 %}}
2023-06-05 21:20:37 +00:00
{{% tab title="shortcode (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-22 22:03:24 +00:00
{{% /tab %}}
2023-06-05 21:20:37 +00:00
{{% tab title="partial" %}}
2022-06-22 22:03:24 +00:00
````go
{{ partial "shortcodes/include .html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-06-22 22:03:24 +00:00
"file" "shortcodes/INCLUDE_ME.md"
)}}
````
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 |
2023-07-27 14:07:01 +00:00
|----------------------|----------|------------------|-------------|
2022-06-05 17:31:59 +00:00
| **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/ ) |
2022-06-23 11:22:04 +00:00
| **hidefirstheading** | 2 | `false` | When `true` and the included file contains headings, the first heading will be hidden. This comes in handy, eg. if you include otherwise standalone Markdown files. |
2022-06-05 17:31:59 +00:00
## Examples
2022-10-31 11:10:36 +00:00
### Arbitrary 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" %}}