# Having trouble using shortcode parameter

**URL:** <https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536>\
**Category:** support\
**Created:** [November 11, 2016, 5:42am UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536 "2016-11-11T05:42:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![e85Hc](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@e85Hc](https://discourse.gohugo.io/u/e85Hc)\
**Post date:** [November 11, 2016, 5:42am UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536/1 "2016-11-11T05:42:22Z")

</div>

Here’s what I’m trying to do:

{{ range (readDir “./static/{{.Get 0}}”) }}  
do stuff  
{{ end }}

It doesn’t actually work but I think you get the idea of what I’m attempting. I’m totally unfamiliar with Go and Go templates, so I’d appreciate any suggestions on how to do this.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [November 11, 2016, 6:54am UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536/2 "2016-11-11T06:54:56Z")

</div>

> [@e85Hc](#):
>
> {{ range (readDir “./static/{{.Get 0}}”) }} do stuff{{ end }}

Try something like this:

```auto
$dir := (printf "/static/%s" (.Get 0) )
{{ range (readDir $dir) }}
    do stuff
{{ end }}

```

---

<div class="post-metadata">

**Author:** ![e85Hc](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@e85Hc](https://discourse.gohugo.io/u/e85Hc)\
**Post date:** [November 11, 2016, 8:58am UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536/3 "2016-11-11T08:58:54Z")

</div>

That works. Just had to put those curly braces around the $dir line. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [November 11, 2016, 5:10pm UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536/4 "2016-11-11T17:10:13Z")

</div>

@e85Hc For my own education, would you mind telling me the desired/actual output and use for this was?

---

<div class="post-metadata">

**Author:** ![e85Hc](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@e85Hc](https://discourse.gohugo.io/u/e85Hc)\
**Post date:** [November 12, 2016, 8:51am UTC](https://discourse.gohugo.io/t/having-trouble-using-shortcode-parameter/4536/5 "2016-11-12T08:51:00Z")

</div>

I was using shortcode to insert an image gallery.

The shortcode looks like `{{% gallery folderName rowHeight %}}`

So basically I put a bunch of images in a folder, I supply the folder name in the shortcode and the template constructs the image gallery regardless of how many images there are.
