# Shortcode and partial arguments: how to do this?

**URL:** <https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103>\
**Category:** support\
**Created:** [September 7, 2023, 9:14pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103 "2023-09-07T21:14:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![polkabot](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@polkabot](https://discourse.gohugo.io/u/polkabot)\
**Post date:** [September 7, 2023, 9:14pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/1 "2023-09-07T21:14:42Z")

</div>

Hugo is making me despair. Let’s start with a .md page

```auto
{{<myshortcode title="title">}}

```

then in `myshortcode.html`:

```auto
{{- $var1 := $.Get "title" }}
{{ $var2 := partial "func/FunctionPartial.html" (dict "param" $var1) }}

```

in `func/FunctionPartial.html` how can I read and manipulate the input parameter? They all give errors!

```auto
{{- $myvar := .Get "param) }} <-- execute of template failed at <.Get>: Get is not a method but has arguments
{{- $myvar := (.Get "param") }} <-- error
{{- $myvar := .param }} <-- error
{{- $myvar := .Param }} <-- error

```

I don’t need page context, just to read that parameter and return it decorated, I don’t think I need dot context for that:

```auto
{{ $ret := printf "<p class=\"mt0 white\">%s</p>" $ret }}
{{ return $ret }}

```

More than anything, I would like to understand how to pass parameters from `page > shortcode > partial`.

Using `$.Scratch` I can obtain the result, but I don’t like this way.

Thank you

---

<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:** [September 7, 2023, 9:42pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/2 "2023-09-07T21:42:52Z")

</div>

> [@polkabot](#):
>
> `{{ $myvar := .param }}`

That’s correct, unless the dot isn’t what you think it is, in which case you need to get to the top-level context:

```plaintext
{{ $myvar := $.param }}

```

---

<div class="post-metadata">

**Author:** ![polkabot](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@polkabot](https://discourse.gohugo.io/u/polkabot)\
**Post date:** [September 8, 2023, 3:04pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/3 "2023-09-08T15:04:09Z")

</div>

@jmooring

So what am I doing wrong? Or what am I not knowing?

in my shortcode:

```auto
{{ $tit2 := partial "func/GetCappelloOrari.html" (dict "titolo" $titolo) }}

```

this is `func/GetCappelloOrari.html` (all code is here)

```auto
{{- $ret := $.titolo }}
{{- return $ret }}

```

Hugo says:  
`execute of template failed at <$.titolo>: can’t evaluate field titolo in type *hugolib.ShortcodeWithPage`

and highlight this:  
`{{- $ret := $.titolo }}`

---

<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:** [September 8, 2023, 3:19pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/4 "2023-09-08T15:19:00Z")

</div>

I don’t have enough information. Please post a link to the public repository for your project.

See [Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132).

> Let us see your code
> 
> Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
> 
> If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

---

<div class="post-metadata">

**Author:** ![polkabot](https://avatars.discourse-cdn.com/v4/letter/p/9fc29f/32.png) [@polkabot](https://discourse.gohugo.io/u/polkabot)\
**Post date:** [September 8, 2023, 3:51pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/5 "2023-09-08T15:51:13Z")

</div>

@jmooring

Thanks, I understand that you need me to create a dummy repo, but you create two files first before I create a dummy repo.

make a shortcode with just this line:

```auto
{{ $tit2:= partial "func/GetCappelloOrari.html" (dict "title" "ciaone") }}

```

make a partial with just these 2 lines:

```auto
{{- $ret := $.title }}
{{- return $ret }}

```

If you don’t get any errors, it means I’ll have to wait for a next version of Hugo, maybe.

Even closing and reopening Hugo seems to have no effect.

---

<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:** [September 8, 2023, 3:52pm UTC](https://discourse.gohugo.io/t/shortcode-and-partial-arguments-how-to-do-this/46103/6 "2023-09-08T15:52:35Z")

</div>

> [@polkabot](#):
>
> you create two files first

I’ve already done that, and cannot reproduce the error.

> [@polkabot](#):
>
> create a dummy repo

Please.

> [@polkabot](#):
>
> I’ll have to wait for a next version

This is a “you” problem not a Hugo problem.
