How to comment out shortcodes in markdown

Hello there,

I was wondering if anyone could tell me if it is possible to somehow comment out shortcodes in markdown content…

For example I have the following shortcode ->

{{% HOVER_POPUP %}} "visible text" "This is my content with markdown **inside of it** hope it helps..." {{% /HOVER_POPUP %}}

But…I have not yet actually made the shortcode. Is there a way I can comment out the whole thing in my markdown file so that hugo doesn’t crack a bananna and stop building the site?

…or alternatievly, is there a way to force hugo to build the page even if its got an error? (such as the markdown file not existing?)

Thank you kindly for any time you can give
John

Try {{/* at the begging of the shortcode and */}} at the end of the shortcode. On phone, so can’t test if this is the syntax for commenting out Golang’s templating curlies, but hopefully my memory serves…

Thank you!

{{/* % reference %}} GlossaryChooseTheRightAvenue {{% /reference % */}}

or

{{/* % reference % */ }} GlossaryChooseTheRightAvenue {{% /* /reference % */}}

No luck :frowning: This code above gives me, Unable to locate template for shortcode “” in page…etc…

Try surrounding the existing shortcode with comments:

{{/* {{% reference %}} GlossaryChooseTheRightAvenue {{% /reference %}} */}}
1 Like
[//]: # Here comes the text

Not tested - hope this works.

Really surprised there isn’t a definitive answer to this very basic of questions.

I searched the themes and found some examples of each:

hugo-bare-min-theme/exampleSite/content/about.md:[//]: # "Exported with love from a post written in Org mode"
apricot-hugo-theme/temp.md:{{/* remove leading "/" if present, but not if there are "//" */}}

And this:

https://stackoverflow.com/questions/45224766/how-to-comment-out-content-in-hugo

Please keep in mind that this has to do with the markdown renderer. And in Hugo’s case it’s Blackfriday. There you’ll find probably the best answers.

And of course in the docs as well: Content formats | Hugo

1 Like

Hello all,

Sorry for the delay, and thank you kindly for all your helps…

I am still struggling to get this to work. I gather there is no definitive guide to commenting anywhere? :slight_smile:

I can comment out content etc, had no problem with that…but I am writing content before my shortcodes exist, and want to be able to write shortcodes in, but comment them out…

I think I am going crazy, because I have tried so many things;

Starting from scratch now; I have tried the following; All of which fail…

[//]: # {{% reference % }} GlossaryChooseTheRightAvenue {{% /reference %}} 

{{/* % reference % }} GlossaryChooseTheRightAvenue {{% /reference % /*}} 

{{/* % reference % */ }} GlossaryChooseTheRightAvenue {{% /* /reference % /*}} 

<!-- {{% HOVER_POPUP %}} "visible text" "This is my content with markdown **inside of it** hope it helps..." {{% /HOVER_POPUP %}} -->

Wait on…I have found that this below works (but why not on the one above)?!

<!-- {{%reference%}} GlossaryChooseTheRightAvenue {{%/reference %}} -->

Frustration is getting the better of me…and it’s a bit of a worry this is so difficult…does anyone else have any suggestions?

Maybe the better practice is just to have blank shortcodes, and avoid trying to comment them out?

Thank you

I assume this worked for you because you put the shortcode within an HTML comment, and you can write HTML in Markdown.

So,

The “shortcode comment” syntax was added by me as a way to add shortcode examples to the documentation (i.e. preventing them to be processed as shortcodes).

{{/*% reference % */}} GlossaryChooseTheRightAvenue {{/*% /reference %*/}}

The above will do that, but it will not hide it, on the contrary.

So if you want to hide it, too, you need to surround it with HTML comment syntax:

<!--{{/*% reference % */}} GlossaryChooseTheRightAvenue {{/*% /reference %*/}}-->
5 Likes

Thanks guys for all your help…and going the extra mile…

I find that syntax is hard on the eyes to say the very least…

I’m still having problems in some places, but perhaps its just my inexperience with shortcodes as well…I dont have anymore time to sink into it…I think I will just write my shortcodes first as the best course of action :slight_smile:

Thank you!
John

I would suggest that you just remove/delete the shortcodes you don’t need. You should rely on source control (Git etc.) to find old content.

1 Like

Thanks Bep, I will consider that…

I think though, my current situation is that I am currently mocking content…not sure that’s a viable solution…well it is, I suppose, just not the best one…

The last thing you want when mocking content is to be messing with other things…(e.g. at the moment Im working on a work around to a work around, and I have no idea what I was actually thinking when I got to the work around) :)…its a horrible situation… haha

Just would be nice to have a way where one can comment a whole bunch of stuff in markdown files and have it completly ignored…I can’t see that there is, without a fine grained comb…

Thank you!
John

1 Like