Include
The include
shortcode includes other pages, resources or files from your project.
Usage
{{% include file="shortcodes/include/INCLUDE_ME.md" %}}
{{% include "shortcodes/include/INCLUDE_ME.md" %}}
{{ partial "shortcodes/include .html" (dict
"page" .
"file" "shortcodes/include/INCLUDE_ME.md"
)}}
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 | <empty> | The path to the page, resource or file to be included. Page and resource paths adhere to Hugo’s logical path. If not found by logical path it falls back to Hugo’s build-in readFile function |
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. |
Settings
Enabling Link Warnings
Option Front Matter You can use include.errorlevel
to control what should happen if a local link can not be resolved to a resource.
If not set or empty, any unresolved link is written as given into the resulting output. If set to warning
the same happens and an additional warning is printed in the built console. If set to error
an error message is printed and the build is aborted.
Please note that this can not resolve files inside of your static
directory. The file must be a resource of the page or the site.
Link warnings are also available for images & links and the openapi shortcode.
[include]
errorlevel = 'warning'
include:
errorlevel: warning
{
"include": {
"errorlevel": "warning"
}
}
Examples
Arbitrary Content
{{% include "shortcodes/include/INCLUDE_ME.md" %}}
You can add standard markdown syntax:
...and even source code
the possibilities are endless (almost - including other shortcodes may or may not work) (almost - including other shortcodes may or may not work)
-
Et Cetera (English: /ɛtˈsɛtərə/), abbreviated to etc., etc, et cet., is a Latin expression that is used in English to mean “and other similar things”, or “and so forth” ↩︎