# How to render shortcode in partials which were defined in a data variable?

**URL:** <https://discourse.gohugo.io/t/how-to-render-shortcode-in-partials-which-were-defined-in-a-data-variable/23745>\
**Category:** support\
**Created:** [February 29, 2020, 12:25pm UTC](https://discourse.gohugo.io/t/how-to-render-shortcode-in-partials-which-were-defined-in-a-data-variable/23745 "2020-02-29T12:25:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zwotzie](https://avatars.discourse-cdn.com/v4/letter/z/edb3f5/32.png) [@zwotzie](https://discourse.gohugo.io/u/zwotzie)\
**Post date:** [February 29, 2020, 12:25pm UTC](https://discourse.gohugo.io/t/how-to-render-shortcode-in-partials-which-were-defined-in-a-data-variable/23745/1 "2020-02-29T12:25:40Z")

</div>

I want to use the a theme ([https://themes.gohugo.io//theme/meghna-hugo/](https://themes.gohugo.io//theme/meghna-hugo/)) and do not like to write my email address in plain. So usualy I want to obfuscate it with javascript. But I guess it could be nice to have this ability to do this on other places too.

I just updated Hugo to the newest available Version: v065.3 (Mac)

in contact.yml I have:

```auto
contact:
 ...
  contact_Details :
    - icon : fas fa-at
      info : "Email: {{< email >}}"

```

in layouts/partials/contact.html:

```auto
...
<span>{{ .info }}</span>
...

```

layouts/shortcodes/email.html

```auto
some html and js

```

And it will render as is defined in yml = htmlcode looks like the yml variable value.

Second example:  
i18n/de.yaml

```auto
- id: copyright 
  translation: Copyright &copy; 2019-{{< year >}}

```

will render with an error:

```auto
Error: add site dependencies: load resources: loading translations: "/Users/rh/Nextcloud/Website/webserver/aefachso.de/meghna-hugo/aefachso/i18n/de.yaml:1:1": failed to load translations: unable to parse translation #6 because template: Copyright &copy; 2019-{{< year >}}:1: unexpected "<" in command
map[id:copyright translation:Copyright &copy; 2019-{{< year >}}]

```

Is there a solution for these “features” or a workaround?

---

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [February 29, 2020, 3:00pm UTC](https://discourse.gohugo.io/t/how-to-render-shortcode-in-partials-which-were-defined-in-a-data-variable/23745/2 "2020-02-29T15:00:24Z")

</div>

> [@zwotzie](#):
>
> Is there a solution for these “features” or a workaround?

I don’t know of a way to include a shortcode in a translation file.

What I did for one of my websites was use a custom value in the text (for example, `{{year}}`). Then in the template code I look if the string contains that value. When it does, I use [`replace`](https://gohugo.io/functions/replace/) to replace `{{year}}` with the proper string.

This way you can ‘inject’ any Hugo-rendered code into a text.
