# HTML comment bug (?)

**URL:** <https://discourse.gohugo.io/t/html-comment-bug/53349>\
**Category:** support\
**Created:** [February 1, 2025, 12:38pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349 "2025-02-01T12:38:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [February 1, 2025, 12:38pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/1 "2025-02-01T12:38:31Z")

</div>

Hello,

On one of my sites, I prepare internal links, but keep them as comments until the target page is online.

```auto
<!-- 💡 [More on *my subject*]({{< relref "my-subject" >}}) -->

```

Once the target page is online, I uncomment and it’s perfect. I find that HTML comments are much better than the old shortcode. Thanks a lot!

But…

I’ve just authorized the use of HTML code on my site:

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

```

And now the `relref` shortcode is evaluated in the comment:

```auto
ERROR [en] REF_NOT_FOUND: Ref “my-subject”:...

```

The error is logical. But evaluating a shortcode in a comment is less logical.

An idea to solve this problem (bug?).

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [February 1, 2025, 2:34pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/2 "2025-02-01T14:34:50Z")

</div>

> [@nfriedli](#):
>
> An idea to solve this problem (bug?).

Shortcodes will always be rendered, even if they’re inside HTML comments. Imagine a shortcode that renders … comments, there’s no way for Hugo to know that this is supposed to be blanked out.

---

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [February 1, 2025, 4:31pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/3 "2025-02-01T16:31:18Z")

</div>

> [@bep](#):
>
> Shortcodes will always be rendered, even if they’re inside HTML comments. Imagine a shortcode that renders … comments, there’s no way for Hugo to know that this is supposed to be blanked out.

So it is now impossible to comment on a part of a markdown source if it contains shortcodes ☹

---

<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 1, 2025, 6:32pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/4 "2025-02-01T18:32:16Z")

</div>

> [@nfriedli](#):
>
> now

I’m not sure what you mean by “now”, but with this site configuration…

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

```

And this Markdown…

```plaintext
<!-- 💡 [More on *my subject*]({{< relref "my-subject" >}}) -->

```

Hugo has been rendering the shortcode since v0.54.0 (that’s the earliest version I tested). So, with respect to including shortcode calls within HTML comments with the site config above, nothing has changed between then and “now”.

---

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [February 1, 2025, 7:19pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/5 "2025-02-01T19:19:15Z")

</div>

You’re right, jmooring. By now, I meant: after passing from the `{{< comment >}} {{</ comment >}}` shorcode to the HTML `<! -- -->` comment.

I was sure that the shortcode allowed the use of uninterpreted `relref`. But I was wrong.

**The lesson.** Always test rather than use your memory…

Sorry to have wasted your time.

---

<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 1, 2025, 7:20pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/6 "2025-02-01T19:20:58Z")

</div>

> [@nfriedli](#):
>
> Sorry to have wasted your time.

No worries. You have not. Given recent changes it was a worthwhile testing exercise.

---

<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 3, 2025, 7:21pm UTC](https://discourse.gohugo.io/t/html-comment-bug/53349/7 "2025-02-03T19:21:54Z")

</div>

Closed on February 3, 2025, 7:21pm UTC

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