# Using isset on shortcode .Params causes error

**URL:** <https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594>\
**Category:** support\
**Created:** [January 24, 2023, 5:11am UTC](https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594 "2023-01-24T05:11:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![will](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/will/32/18403_2.png) [@will](https://discourse.gohugo.io/u/will)\
**Post date:** [January 24, 2023, 5:11am UTC](https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594/1 "2023-01-24T05:11:59Z")

</div>

If a shortcode has this

```auto
{{ if isset .Params "project_url" }}
    {{ warnf "foo" }}
{{ end }}

```

then there’s an error on the `isset .Params` line

```auto
 "/Users/me/Developer/project/exampleSite/content/blog/my-shortcode.md:17:1": failed to render shortcode "myshortcode": failed to process shortcode: "/Users/me/Developer/project/layouts/shortcodes/project/myshortcode.html:42:6": execute of template failed at <isset .Params "project_url">: error calling isset: isset unable to use key of type string as index 

```

even though this is straight out of [the isset documentation](https://gohugo.io/functions/isset/):

> {{ if isset .Params “project\_url” }} {{ index .Params “project\_url” }}{{ end }}

If you change

```auto
{{ if isset .Params "project_url" }}

```

to

```auto
{{ if isset .Page.Params "project_url" }}

```

then it works.

Env:

```auto
$ hugo env
hugo v0.110.0+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.19.5"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"

```

---

<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:** [January 24, 2023, 4:10pm UTC](https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594/2 "2023-01-24T16:10:48Z")

</div>

`.Params` within the context received by a shortcode is an array of the positional or named shortcode parameters. If you call the shortcode without any parameters, `.Params` is nil.

`.Page.Params` within the context received by a shortcode refers to front matter parameters.

[https://gohugo.io/templates/shortcode-templates/#params](https://gohugo.io/templates/shortcode-templates/#params)

---

<div class="post-metadata">

**Author:** ![will](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/will/32/18403_2.png) [@will](https://discourse.gohugo.io/u/will)\
**Post date:** [January 24, 2023, 8:23pm UTC](https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594/3 "2023-01-24T20:23:40Z")

</div>

I think `.Params` is a map, isn’t it?

In my case, there were other params set, so `.Params` wasn’t nil. Even if `.Params` was nil, “isset unable to use key of type string as index” wouldn’t be a good explanation of the problem.

---

<div class="post-metadata">

**Author:** ![will](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/will/32/18403_2.png) [@will](https://discourse.gohugo.io/u/will)\
**Post date:** [January 24, 2023, 8:27pm UTC](https://discourse.gohugo.io/t/using-isset-on-shortcode-params-causes-error/42594/4 "2023-01-24T20:27:13Z")

</div>

Here’s the original context:

> <https://github.com/willfaught/paige/blob/master/layouts/shortcodes/paige/vimeo.html#L38>

Changing

```auto
{{ if and (ne $byline nil) (ne $byline "") }}

```

to

```auto
{{ if isset .Params "byline" }}

```

will cause the error.

Edit: Fixed the example changed code.
