shortcodes.md (1921B)
1 ---
2 title: Shortcode Variables
3 linktitle: Shortcode Variables
4 description: Shortcodes can access page variables and also have their own specific built-in variables.
5 date: 2017-03-12
6 publishdate: 2017-03-12
7 lastmod: 2017-03-12
8 categories: [variables and params]
9 keywords: [shortcodes]
10 draft: false
11 menu:
12 docs:
13 parent: "variables"
14 weight: 20
15 weight: 20
16 sections_weight: 20
17 aliases: []
18 toc: false
19 ---
20
21 [Shortcodes][shortcodes] have access to parameters delimited in the shortcode declaration via [`.Get`][getfunction], page- and site-level variables, and also the following shortcode-specific fields:
22
23 .Name
24 : Shortcode name.
25
26 .Ordinal
27 : Zero-based ordinal in relation to its parent. If the parent is the page itself, this ordinal will represent the position of this shortcode in the page content.
28
29 .Page
30 : The owning ´Page`.
31
32 .Parent
33 : provides access to the parent shortcode context in nested shortcodes. This can be very useful for inheritance of common shortcode parameters from the root.
34
35 .Position
36 : Contains [filename and position](https://godoc.org/github.com/gohugoio/hugo/common/text#Position) for the shortcode in a page. Note that this can be relatively expensive to calculate, and is meant for error reporting. See [Error Handling in Shortcodes](/templates/shortcode-templates/#error-handling-in-shortcodes).
37
38 .IsNamedParams
39 : boolean that returns `true` when the shortcode in question uses [named rather than positional parameters][shortcodes]
40
41 .Inner
42 : represents the content between the opening and closing shortcode tags when a [closing shortcode][markdownshortcode] is used
43
44 [getfunction]: /functions/get/
45 [markdownshortcode]: /content-management/shortcodes/#shortcodes-with-markdown
46 [shortcodes]: /templates/shortcode-templates/
47
48 .InnerDeindent {{< new-in "0.100.0" >}}
49 : Gets the `.Inner` with any indentation removed. This is what's used in the built-in `{{</* highlight */>}}` shortcode.
50
51
52