# Range variable from frontmatter using shortcode

**URL:** <https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396>\
**Category:** support\
**Created:** [July 7, 2022, 11:45am UTC](https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396 "2022-07-07T11:45:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prajkt\_Yeole](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/prajkt_yeole/32/13817_2.png) [@Prajkt\_Yeole](https://discourse.gohugo.io/u/Prajkt_Yeole)\
**Post date:** [July 7, 2022, 11:45am UTC](https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396/1 "2022-07-07T11:45:51Z")

</div>

Hello, I’m trying to get the variable from frontmatter through shortcode and range it inside the shortcode to show it on the markdown file.

Frontmatter -

```auto
---
code_snippet_1:
    - language: Python
      modes:
        - name: API Mode
          content: api mode content code
        - name: Proxy Mode
          content: proxy mode content code
    - language: Node Js
      modes:
        - name: API Mode
          content: api mode content code
        - name: Proxy Mode
          content: proxy mode content code
---

```

My Shortcode -

```auto
{{< code-snippet "code_snippet_1" >}}

```

My Shortcode content -

```auto
{{ $snip := (.Get 0)}}

{{ range (index .Page.Params $snip) }}
    {{ .language }}
{{ end }}

```

I don’t seem to understand the issue if anybody can help. I know ranging with $ is not possible.

Thanks.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [July 7, 2022, 2:50pm UTC](https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396/2 "2022-07-07T14:50:08Z")

</div>

The front matter, markdown, and template code that you posted work as expected. What’s the problem?

---

<div class="post-metadata">

**Author:** ![Prajkt\_Yeole](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/prajkt_yeole/32/13817_2.png) [@Prajkt\_Yeole](https://discourse.gohugo.io/u/Prajkt_Yeole)\
**Post date:** [July 7, 2022, 3:18pm UTC](https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396/3 "2022-07-07T15:18:49Z")

</div>

ah, my bad, apologies. you can delete the question if required.

Appreciate your efforts @jmooring

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [July 7, 2022, 3:19pm UTC](https://discourse.gohugo.io/t/range-variable-from-frontmatter-using-shortcode/39396/4 "2022-07-07T15:19:43Z")

</div>

Archived on July 7, 2022, 3:19pm UTC


