HTML comment bug (?)

Hello,

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

<!-- đź’ˇ [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:

[markup.goldmark.renderer]
unsafe = true

And now the relref shortcode is evaluated in the comment:

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?).

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.

2 Likes

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

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

[markup.goldmark.renderer]
unsafe = true

And this Markdown…

<!-- đź’ˇ [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”.

1 Like

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.

1 Like

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

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