# all·markdown

How to write a comment in Markdown

Try it — edit the markdown and watch the preview

Result

Runs entirely in this tab. Open the full editor to work on a real document.

Markdown has no comment syntax. There is no // and no # that means “ignore this line”. What people call a Markdown comment is one of three workarounds.

The HTML comment

The usual answer, and the most portable:

<!-- reminder: update these figures before publishing -->

Most renderers pass HTML through untouched, and browsers never display a comment, so it vanishes from the page.

For renderers that strip HTML entirely:

[//]: # (reminder: update these figures)

This declares a link labelled // that nothing references. The parser consumes it and emits nothing. It is uglier, and it is the only option when HTML is disabled.

Front matter

If the note is really metadata — a status, an author, a draft flag — put it in YAML front matter at the top of the file instead. That is what front matter is for, and All Markdown hides it from the preview automatically.

A comment is not private

All three approaches remove text from the rendered page, not from the file. Anyone who opens the source, views source in a browser, or reads the repository sees it. Do not put credentials, unpublished figures or anything you would not say out loud in a comment.

Common questions

Does Markdown have a comment syntax?
No. There is no official comment marker, which is why several workarounds exist. All of them borrow syntax that happens to produce no visible output.
What is the most portable way to write a comment?
An HTML comment — <!-- like this -->. Most renderers pass HTML through and browsers do not display comments, so it disappears from the rendered page.
Is an HTML comment actually private?
No. It is removed from the visible page but remains in the source, so anyone who views source or reads the file can see it. Never put anything sensitive in one.
What is the [//]: # trick?
An unused link definition. The parser recognises the label, produces no output, and the text after it is treated as the link title. It survives renderers that strip HTML, which is its only real advantage.
Why is my comment showing up as text?
Either the renderer has HTML disabled for safety, or the comment is indented into a code block. Inside a fenced or indented block nothing is interpreted, so the comment appears verbatim.