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