# HELP! Shortcode generating additional \<p\> tags

**URL:** <https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537>\
**Category:** support\
**Tags:** shortcodes\
**Created:** [February 14, 2025, 10:11pm UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537 "2025-02-14T22:11:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thecloudxpert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/thecloudxpert/32/23904_2.png) [@thecloudxpert](https://discourse.gohugo.io/u/thecloudxpert)\
**Post date:** [February 14, 2025, 10:11pm UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/1 "2025-02-14T22:11:32Z")

</div>

Let me first say i’m relatively new to hugo (and the forum), but I am trying to create a shortcode (note.html) to highlight some info text on my website but it seems to generate additional p tags. I’m using the clarity framework as the source of my CSS but i don’t feel that is what’s causing the issue

the note.html code is:

```auto
<!-- note -->
<!-- danger, warning, info, static -->

<div {{ with .Get "type" }}class="alert alert-{{.}} note"{{ end }} role="alert">
<div class="clr-row">
<div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
<div class="title">
Note:
</div>
</div>
<div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
{{ .Inner }} 
</div>
</div>
</div>

<!-- note -->

```

In the markdown, i’m calling the shortcode:

```auto
{{% note type="info" %}}

The list is not meant as an exhaustive list of possible solutions, but as an example of the power and flexibility the product.

{{% /note %}}

```

The result is the following html:

```auto
<div class="alert alert-info note" role="alert">
  <div class="clr-row">
    <div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
      <div class="title">
        Note:
      </div>
    </div>
    <div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
      <p>The list is not meant as an exhaustive list of possible solutions, but as an example of the power and flexibility the product.</p>
    </div>
  </div>
</div>

```

I’m not sure if it is the use of the {{.Inner}} or whether its working as designed or i am doing something wrong else where but it makes the aesthetics of the page off with the additional blank line!

 ![hugo](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/d/d/dd228cf7c36dee9c4773fb592a150a328836fb89.png)

---

<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:** [February 15, 2025, 12:11am UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/2 "2025-02-15T00:11:09Z")

</div>

You’re calling the shortcode using the `{{% .. %}}` [notation](https://gohugo.io/content-management/shortcodes/#notation) so everything is processed as Markdown. When rendering Markdown to HTML, a single [line](https://spec.commonmark.org/0.31.2/#line) of text is rendered to a [paragraph](https://spec.commonmark.org/0.31.2/#paragraphs). Test it with the [reference implementation](https://spec.commonmark.org/dingus/?text=The%20list%20is%20not%20meant%20as%20an%20exhaustive%20list%20of%20possible%20solutions%2C%20but%20as%20an%20example%20of%20the%20power%20and%20flexibility%20the%20product.%0A) of the renderer.

With this shortcode call:

```plaintext
{{% note type="info" %}}

foo

{{% /note %}}

```

The value of `.Inner` is:

```auto
\n\nfoo\n\n

```

You can strip leading and trailing whitespace (including new lines) with the [`strings.TrimSpace`](https://gohugo.io/functions/strings/trimspace/) function, e.g.

```plaintext
{{ .Inner | strings.TrimSpace }}

```

---

<div class="post-metadata">

**Author:** ![thecloudxpert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/thecloudxpert/32/23904_2.png) [@thecloudxpert](https://discourse.gohugo.io/u/thecloudxpert)\
**Post date:** [February 15, 2025, 12:51am UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/3 "2025-02-15T00:51:21Z")

</div>

Thank you so much! that worked perfectly for all the notes without any markdown in them but as soon as I used markdown, didn’t work.

i.e.

```auto
{{< note type="info" >}}
The **Network** tab allows us to inspect the network activity within the browser. We will use this to capture the API call made by using the user interface. For more information, see the Google Chrome article [Inspect network activity](https://developer.chrome.com/docs/devtools/network).
{{< /note >}}

```

changed to:

```auto
<div class="alert alert-info note" role="alert">
<div class="clr-row">
<div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
<div class="title">
Note:
</div>
</div>
<div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
The **Network** tab allows us to inspect the network activity within the browser. We will use this to capture the API call made by using the user interface. For more information, see the Google Chrome article [Inspect network activity](https://developer.chrome.com/docs/devtools/network). 
</div>
</div>
</div>

```

and didn’t recognise the \*\*Network\*\* as **Network** or the url shortcode.

Again it’s probably my lack of understanding of the Hugo syntax.

---

<div class="post-metadata">

**Author:** ![thecloudxpert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/thecloudxpert/32/23904_2.png) [@thecloudxpert](https://discourse.gohugo.io/u/thecloudxpert)\
**Post date:** [February 15, 2025, 1:02am UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/4 "2025-02-15T01:02:12Z")

</div>

i think i just solved it with markdownify…

```auto
<!-- danger, warning, info, static -->

<div {{ with .Get "type" }}class="alert alert-{{.}} note"{{ end }} role="alert">
<div class="clr-row">
<div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
<div class="title">
Note:
</div>
</div>
<div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
{{ .Inner | strings.TrimSpace | markdownify}} 
</div>
</div>
</div>

<!-- note -->

```

which now shows as:

```auto
<div class="alert alert-info note" role="alert">
<div class="clr-row">
<div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
<div class="title">
Note:
</div>
</div>
<div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
The <strong>Network</strong> tab allows us to inspect the network activity within the browser. We will use this to capture the API call made by using the user interface. For more information, see the Google Chrome article <a href="https://developer.chrome.com/docs/devtools/network" target="_blank" rel="nofollow noopener noreferrer">Inspect network activity</a>. 
</div>
</div>
</div>

```

---

<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:** [February 15, 2025, 1:23am UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/5 "2025-02-15T01:23:47Z")

</div>

I would do this instead…

1) Call the shortcode using the `{{< >}}` notation.

```plaintext
{{< note type="info" >}}

**foo**

{{< /note >}}

```

2) Update the shortcode

```plaintext
<div {{ with .Get "type" }}class="alert alert-{{.}} note"{{ end }} role="alert">
  <div class="clr-row">
    <div class="clr-col-xl-1 clr-col-lg-1 clr-col-md-1 clr-col-sm-1">
      <div class="title">
        Note:
      </div>
    </div>
    <div class="clr-col-xl-11 clr-col-lg-11 clr-col-md-11 clr-col-sm-11">
      {{ .Inner | .Page.RenderString }}
    </div>
  </div>
</div>

```

Note that since were not processing the shortcode as Markdown, we can indent the markup as much as we want.

And you don’t need to set this in your site configuration:

```plaintext
[markup.goldmark.renderer]
unsafe = true

```

---

<div class="post-metadata">

**Author:** ![tyco](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tyco/32/23754_2.png) [@tyco](https://discourse.gohugo.io/u/tyco)\
**Post date:** [February 15, 2025, 4:25am UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/6 "2025-02-15T04:25:11Z")

</div>

@thecloudxpert See also [Hugo-admonitions: A simple way to add beautiful Callouts to hugo site](https://discourse.gohugo.io/t/hugo-admonitions-a-simple-way-to-add-beautiful-callouts-to-hugo-site/52576)

---

<div class="post-metadata">

**Author:** ![thecloudxpert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/thecloudxpert/32/23904_2.png) [@thecloudxpert](https://discourse.gohugo.io/u/thecloudxpert)\
**Post date:** [February 15, 2025, 9:34pm UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/7 "2025-02-15T21:34:39Z")

</div>

That seems to have worked like a dream! thank you again for being so helpful!

---

<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:** [February 17, 2025, 9:34pm UTC](https://discourse.gohugo.io/t/help-shortcode-generating-additional-p-tags/53537/8 "2025-02-17T21:34:48Z")

</div>

Closed on February 17, 2025, 9:34pm UTC

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