# Using hugo templates ({{) in markdown file

**URL:** <https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828>\
**Category:** support\
**Created:** [October 6, 2022, 12:10am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828 "2022-10-06T00:10:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugoblogger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hugoblogger/32/17901_2.png) [@hugoblogger](https://discourse.gohugo.io/u/hugoblogger)\
**Post date:** [October 6, 2022, 12:10am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/1 "2022-10-06T00:10:35Z")

</div>

Is it possible to use template syntax (say `{{ .Params... }}` or `{{ range ... }}`) in a markdown post file?

I am trying to use a shortcode (say `figure`) in a post over an array of items (possibly from the `params` in the config file)

---

<div class="post-metadata">

**Author:** ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)\
**Post date:** [October 6, 2022, 4:30am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/2 "2022-10-06T04:30:25Z")

</div>

You can enable **Inline Shortcodes**

> **[Create Your Own Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes)**
>
> You can extend Hugo's built-in shortcodes by creating your own using the same templating syntax as that for single and list pages.

---

<div class="post-metadata">

**Author:** ![hugoblogger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hugoblogger/32/17901_2.png) [@hugoblogger](https://discourse.gohugo.io/u/hugoblogger)\
**Post date:** [October 6, 2022, 5:37am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/3 "2022-10-06T05:37:17Z")

</div>

Thanks for the link.

While I was able to enable inline short codes and use say `<figure>` itself in the post markdown file. I am not still able to use function like `{{ range }}`.

What I am trying to do is along these lines:

```auto
{{ range $index, $element := .Site.Params }}
{{< figure src="{{ $element }}" title="Image {{ $index }}" >}}
{{ end }}

```

However, it is rendered as follows:

![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/1/8/18a782fd87a858d427b74534ad4552e4d328e390.png)

---

<div class="post-metadata">

**Author:** ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)\
**Post date:** [October 6, 2022, 6:18am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/4 "2022-10-06T06:18:13Z")

</div>

The inner body of inline shortcodes is shortcode template context, you cannot call shortcodes i.e.  
`{{< figure >}}` inside the body of inline shortcodes.

---

<div class="post-metadata">

**Author:** ![hugoblogger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/hugoblogger/32/17901_2.png) [@hugoblogger](https://discourse.gohugo.io/u/hugoblogger)\
**Post date:** [October 6, 2022, 6:23am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/5 "2022-10-06T06:23:53Z")

</div>

Not sure if I explained it right but I was try to explain the following:

In my post (markdown file), I am able to use `{{<figure ...}}` standalone. So `enableInlineShortCodes = true` worked. But `{{ range ... }}` does not work irrespective of what’s inside the range block - another shortcode or simple text.

---

<div class="post-metadata">

**Author:** ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)\
**Post date:** [October 6, 2022, 8:19am UTC](https://discourse.gohugo.io/t/using-hugo-templates-in-markdown-file/40828/6 "2022-10-06T08:19:24Z")

</div>

calling a `{{< figure ... >}}` shortcode in markdown is normal usage of shortcode.  
**Inline Shortcodes** is like this:

example defining inline shortcode template with name `my_shortcode`.

```nohighlight
<!-- post.md -->

{{< my_shortcode.inline >}}

<pre>
{{ range $index, $element := .Site.Params }}
  {{ $index }} : {{ $element }}
{{ end }}
</pre>

{{< /my_shortcode.inline >}}

```
