The file shortcode prints the full content of any given file with syntax highlighting.
file shortcode prints and highlights the full content of a given input file. It recognizes the
languages supported by Hugo’s highlight function
idfield fails when embedding (multiple)
fileshortcodes in an example. Provide an explicit, unique
idto prevent cross-interference.
The shortcode supports the following arguments:
|path||Yes||Path of the input file. The path is relative to the |
|lang||No||Language to be used by the syntax highlighter. When no language is specified, the shortcode derives the language from the input file’s extension.|
|show||No||If unset, shows the panel with the code snippet in collapsed state. By default, the panel is expanded.|
|full||No||If unset, shows the filename only. By default, the full relative path is shown.|
|id||No||Optional id of the collapse panel, defaults to “file-collapse-n” with a sequential number n starting at 1.|
|class||No||Optional class argument of the tab control.|
Change the style and language of your file preview with shortcode arguments.
path argument to print the content of a specific file. By default, the shortcode uses the site’s
basePath (see page layout for more information).
Provide a path that starts with
./ to use the path of the repository as base path instead.
false to hide the file content on page load. The content is reveiled when clicking the tab control.
false to show the filename only.