# Shortcode syntax example within a code block is being executed

**URL:** <https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494>\
**Category:** support\
**Created:** [November 8, 2021, 7:28am UTC](https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494 "2021-11-08T07:28:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuanyi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yuanyi/32/15090_2.png) [@yuanyi](https://discourse.gohugo.io/u/yuanyi)\
**Post date:** [November 8, 2021, 7:28am UTC](https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494/1 "2021-11-08T07:28:31Z")

</div>

Hi there,

I was writing a note about Hugo, just trying to explain how templates can be called and I wrote something like this in the Markdown file:

```auto
- Partial： `{{ partial "<PATH>/<PARTIAL>.html" . }}`
- Shortcode： `{{% shortcodename parameters %}}`

```

When I start `hugo server` or `hugo` it throw an error:

```auto
hugo server
Start building sites …
hugo v0.87.0-B0C541E4+extended windows/amd64 BuildDate=2021-08-03T10:57:28Z VendorInfo=gohugoio
Error: Error building site: "C:\Users\Hippocrene\projects\blog\yuanyiblog\content\posts\hugo.md:209:17": failed to extract shortcode: template for shortcode "shortcodename" not found

```

I wonder why my content in code blocks has been executed? How can I avoid this?

Thank you.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [November 8, 2021, 8:53am UTC](https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494/2 "2021-11-08T08:53:12Z")

</div>

I have amended the topic title because the issue pertains to the shortcode syntax -and not the partial-.

Also I can reproduce it, but I don’t have the time to debug it.

The Markdown processor was upgraded in the latest release.  
However this issue also happens when the HTML delimiter is used within a content file’s code block:

e.g.

```auto
`{{< shortcodename parameters >}}`

```

Hopefully the others can have a look.

---

<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:** [November 8, 2021, 7:02pm UTC](https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494/3 "2021-11-08T19:02:54Z")

</div>

Shortcodes are always evaluated, even within code blocks. This has always been the case (at least since v0.54.0). It is not new behavior.

When documenting the use of a shortcode, use this notation:

````auto
My example:

```html
{{</* foo */>}}
{{%/* bar */%}}
```

````

This will render:

![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/e/efc58225e37101eebdfdd5774c45bf980424c6d4.png)

---

<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:** [November 10, 2021, 7:03pm UTC](https://discourse.gohugo.io/t/shortcode-syntax-example-within-a-code-block-is-being-executed/35494/4 "2021-11-10T19:03:36Z")

</div>

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