2020-05-31 09:17:32 -07:00
Include shortcode can include files of different types. By specifying a language, the included file will have syntax highlighting.
2020-04-30 06:37:27 -07:00
## Shortcode
```tpl
{{< /* include file="relative/path/from/hugo/root" language="go" markdown=[false|true] */>}}
```
Attributes:
2020-09-10 13:23:24 -07:00
<!-- prettier - ignore -->
2020-04-30 06:37:27 -07:00
| Name | Usage | default |
|---|---|---|
| file | path to the included file relative to the hugo root | empty value |
| language* | language for [syntax highlighting ](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages ) | empty value |
| markdown | included file is markdown | false |
| options | highlighting [options ](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode ) | linenos=table |
2020-05-31 09:17:32 -07:00
\* if not set, the content will be rendered as plain HTML
2020-04-30 06:37:27 -07:00
2020-09-10 13:23:24 -07:00
### Include \*.yml file with options
2020-04-30 06:37:27 -07:00
```tpl
{{< /* include file="config.yaml" language="yaml" options="linenos=table,hl_lines=5-6,linenostart=100" */>}}
```
2020-06-07 08:42:03 -07:00
<!-- spellchecker - disable -->
2020-09-10 13:23:24 -07:00
2020-04-30 06:37:27 -07:00
{{< include file = "config.yaml" language = "yaml" options = "linenos=table,hl_lines=5-6,linenostart=100" > }}
2020-09-10 13:23:24 -07:00
2020-06-07 08:42:03 -07:00
<!-- spellchecker - enable -->
2020-04-30 06:37:27 -07:00
2020-09-10 13:23:24 -07:00
### Include \*.md file
2020-04-30 06:37:27 -07:00
Included markdown files will be rendered using the `markdownify` filter.
{{< hint warning > }}
**Location of markdown files**\
2020-05-31 09:17:32 -07:00
If you include markdown files that should not get a menu entry, place them outside the content folder or exclude them otherwise.
2020-04-30 06:37:27 -07:00
{{< / hint > }}
```tpl
2020-05-31 09:17:32 -07:00
{{< /* include file="static/includes/table.md.part" markdown="true" */>}}
2020-04-30 06:37:27 -07:00
```
2020-06-07 08:42:03 -07:00
<!-- spellchecker - disable -->
2020-09-10 13:23:24 -07:00
2020-05-31 09:17:32 -07:00
{{< include file = "static/includes/table.md.part" markdown = "true" > }}
2020-09-10 13:23:24 -07:00
2020-06-07 08:42:03 -07:00
<!-- spellchecker - enable -->
2020-04-30 06:37:27 -07:00
2020-09-10 13:23:24 -07:00
### Include \*.html file
2020-04-30 06:37:27 -07:00
2020-05-31 09:17:32 -07:00
HTML content will be filtered by the `safeHTML` filter and added to the rendered page output.
2020-04-30 06:37:27 -07:00
```tpl
2020-05-31 09:17:32 -07:00
{{< /* include file="static/includes/example.html.part" */>}}
2020-04-30 06:37:27 -07:00
```
2020-05-31 09:17:32 -07:00
{{< include file = "static/includes/example.html.part" > }}