Work area in markdown?

Is there any “proper” way to exclude some part of markdown file from rendering? I want to have some work area for personal comments, list of used resources etc. And keep it there even after I publish it.

I’ve tried html comments but those are published too. Putting it into frontmatter section results in errors.

So I’m trying to ask here before I’ll use html comments and strip them myself in my asset compilation pipeline.

1 Like

You could create a shortcode that does nothing.

I presume you’re using JSON then? It doesn’t support comments. If you switch to using TOML, you can add comments with # some comment in front-matter and config files and they will not cause errors.

Hugo has a command to automatically convert front-matter from one format to another, if you want to swap over: hugo convert | Hugo

You can make Hugo preserve HTML comments in your code by wrapping them in a Golang template tag and piping them to/as safeHTML. Example:

{{"<!-- This is a comment //-->" | safeHTML}}

will be preserved as a regular HTML comment: <!-- This is a comment //--> when the site is published. It’s a horrible kludge though and would be a pretty painful process, if you had multiple lines or blocks os code to comment out.

On my end, when using .md files, comments are also not processed by Hugo when using them like this:

text text text

<!--
comment
-->

continue text

The first solution is probably the cleanest one, for now, as far as i know there is no dedicated comment syntax in blackfriday parser.

HTML <!-- --> comments slick out to the HTML output, for me.

There is an ugly solution:

    {{< \"this is a comment" >}}

that raises

Unable to locate template for shortcode “” in page “test1.md”

error during the page build, but it completes.