# Help with nested shortcode

**URL:** <https://discourse.gohugo.io/t/help-with-nested-shortcode/33313>\
**Category:** support\
**Created:** [June 9, 2021, 9:29pm UTC](https://discourse.gohugo.io/t/help-with-nested-shortcode/33313 "2021-06-09T21:29:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdm508](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mdm508/32/14562_2.png) [@mdm508](https://discourse.gohugo.io/u/mdm508)\
**Post date:** [June 9, 2021, 9:29pm UTC](https://discourse.gohugo.io/t/help-with-nested-shortcode/33313/1 "2021-06-09T21:29:16Z")

</div>

Hello everyone. I am trying to create a shortcode to make the creation of tabed code views easier. In my case, I will always be displaying tabs for only two languages. So, I want to make a short code whose arguments are the two code blocks.

```auto
t{{< tabs tabTotal="2" tabName1="Pyret" tabName2="BSL">}}
{{< tab tabNum="1" >}}
<pre>
  {{.Get 0}}
</pre>
{{< /tab >}}
{{< tab tabNum="2" >}}
<pre>
 {{.Get 1}}
</pre>
{{< /tab >}}
{{< /tabs >}}

```

When i tried to make the above into a short code called `code` it did not allow me to reference the tab and tabs shortcodes.

I feel like maybe my entire approach is wrong and I should be using .Parent but i am not really sure how.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [June 9, 2021, 11:44pm UTC](https://discourse.gohugo.io/t/help-with-nested-shortcode/33313/2 "2021-06-09T23:44:20Z")

</div>

> [@mdm508](#):
>
> ```auto
> {{< tab tabNum="1" >}}
> <pre>
> {{.Get 0}}
> </pre>
> {{< /tab >}}
> 
> ```

You need to call `.Get` from inside the shortcode definition (`layouts/shortcodes/foo.html`), not inside the shortcode call from your content. Also, you are using `.Get 0`, which is used for positional parameters, while you have named parameters.

Have a read about shortcode templates here: [Create your own shortcodes | Hugo](https://gohugo.io/templates/shortcode-templates/)

I suggest you start with a smaller example and build up on it.

```auto
<!-- content/test.md -->
{{< foo >}}
{{< bar >}}
bar 1
{{< /bar >}}
{{< bar >}}
bar 2
{{< /bar >}}
{{< /foo >}}

```

```auto
<!-- shortcodes/foo.html -->
begin inner:
<br>{{ .Inner }}<br>
:end inner

```

```auto
<!-- shorcodes/bar.html -->
<br>
begin bar:
<br>{{ .Inner }}<br>
: end bar
<br>

```

Will result in:

```auto
begin inner:

begin bar:
bar 1
: end bar

begin bar:
bar 2
: end bar

:end inner

```

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 15, 2021, 9:59pm UTC](https://discourse.gohugo.io/t/help-with-nested-shortcode/33313/3 "2021-06-15T21:59:55Z")

</div>

Closed on June 15, 2021, 9:59pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
