# Construct a partial call with Data

**URL:** <https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412>\
**Category:** support\
**Created:** [April 6, 2018, 9:01pm UTC](https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412 "2018-04-06T21:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Cabrera](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@Javier\_Cabrera](https://discourse.gohugo.io/u/Javier_Cabrera)\
**Post date:** [April 6, 2018, 9:01pm UTC](https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412/1 "2018-04-06T21:01:52Z")

</div>

Hello,

I’m trying to make a call from within a TOML file data, like so:

```auto
[featured]
current = "peter"

[featured.peter]
img = "/avatar.jpg"
   [featured.peter.btn]
      img = "btn.jpg"
[featured.rose]
img = "/avatar.jpg"
   [featured.rose.btn]
      img = "btn.jpg"

```

What I want is to change the value of current manually for anything I want, so when I call:

{{ .Site.Data.users.featured.current.btn }}

It displays the button info for rose, or peter, or anyone.

Problem is, as you might have guessed, that it shows me “peter” instead of the map.

My idea is to change current = “peter” and that the changes occur everywhere instead of manually changing all those calls.

{{ .Site.Data.users.featured.$current.btn }}

Doesn’t appears to work either, I can’t mix that into a variable.

Any ideas?

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [April 6, 2018, 9:10pm UTC](https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412/2 "2018-04-06T21:10:17Z")

</div>

Use the [`index`](https://gohugo.io/functions/index-function/) function.

Example from my theme: [TOML data](https://gitlab.com/kaushalmodi/hugo-theme-refined/blob/master/data/svg.toml) | [template using `index`](https://gitlab.com/kaushalmodi/hugo-theme-refined/blob/master/layouts/partials/social.html)

_Tweak in the template to make clear what’s happening_:

```auto
(index $.Site.Data.svg "mastodon")

```

That `"mastodon"` string could have been `"mastodon-alt"` too, based on the value of `(.svg | default (.name | lower))` in the template.

---

<div class="post-metadata">

**Author:** ![Javier\_Cabrera](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@Javier\_Cabrera](https://discourse.gohugo.io/u/Javier_Cabrera)\
**Post date:** [April 6, 2018, 10:34pm UTC](https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412/3 "2018-04-06T22:34:01Z")

</div>

thanks for that, kaushalmodi, I was struggling really hard with it. You showed me the path.

Have a cookie \> [https://media.giphy.com/media/1ngQorBCDcUFy/giphy.gif](https://media.giphy.com/media/1ngQorBCDcUFy/giphy.gif)

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [April 6, 2018, 10:53pm UTC](https://discourse.gohugo.io/t/construct-a-partial-call-with-data/11412/4 "2018-04-06T22:53:16Z")

</div>

Thanks! 😄

![](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/8/85d06a7a17486f4e3dd3f728107b95919df213c8.gif)
