--- aliases: - /doc/shortcodes/ date: 2013-07-01 menu: main: parent: extras next: /extras/pagination prev: /extras/permalinks title: Shortcodes weight: 80 toc: true --- Hugo uses Markdown for its simple content format. However, there are a lot of things that Markdown doesn’t support well. We are unwilling to accept being constrained by our simple format. Also unacceptable is writing raw HTML in our Markdown every time we want to include unsupported content such as a video. To do so is in complete opposition to the intent of using a bare bones format for our content and utilizing templates to apply styling for display. To avoid both of these limitations, Hugo created shortcodes. A shortcode is a simple snippet inside a content file that Hugo will render using a predefined template. Note that shortcodes will not work in template files---if you need a functionality like that in a template, you most likely want a [partial template](/templates/partials/) instead. ## Using a shortcode In your content files, a shortcode can be called by using '`{{%/* name parameters */%}}`' respectively. Shortcodes are space delimited (parameters with spaces can be quoted). The first word is always the name of the shortcode. Parameters follow the name. The format for named parameters models that of HTML with the format `name="value"`. Some shortcodes use or require closing shortcodes. Like HTML, the opening and closing shortcodes match (name only), the closing being prepended with a slash. Example of a paired shortcode: {{* highlight go */>}} A bunch of code here {{* /highlight */>}} The examples above use two different delimiters, the difference being the `%` and the `<` character: ### Shortcodes with Markdown The `%` characters indicates that the shortcode's inner content needs further processing by the page's rendering processor (i.e. Markdown), needed to get the **bold** text in the example below: ``` {{%/* myshortcode */%}}Hello **World!**{{%/* /myshortcode */%}} ``` ### Shortcodes without Markdown The `<` character indicates that the shortcode's inner content doesn't need any further rendering, this will typically be pure HTML: ``` {{* myshortcode */>}}
Hello World!
{{* /myshortcode */>}} ``` ## Hugo Shortcodes Hugo ships with a set of predefined shortcodes. ### highlight This shortcode will convert the source code provided into syntax highlighted HTML. Read more on [highlighting](/extras/highlighting/). #### Usage `highlight` takes exactly one required parameter of _language_ and requires a closing shortcode. #### Example {{* highlight html */>}}<html>
<body> This HTML </body>
</html>