The short answer: use an HTML comment for portable notes
Write `<!--` before the note and `-->` after it. A compatible renderer treats that range as raw HTML comment content, so it does not appear as visible prose in the rendered document.
This is HTML syntax embedded in Markdown, not a dedicated Markdown comment feature. That distinction matters because some publishing systems disable or sanitize raw HTML.
# Release notes
<!-- Check the version number before publishing. -->
Version 2.4 is available.Release notes
Version 2.4 is available.| Need | Use | What to expect |
|---|---|---|
| A note hidden from the rendered page | <!-- note --> | Broad compatibility where raw HTML comments are allowed |
| A private secret | Do not put it in Markdown | Anyone with the source may read it |
| An Obsidian-only editing note | %% note %% | Visible only to tools that support Obsidian comments |
| A literal example of comment syntax | A fenced code block | The markers are shown as code |
Single-line and multiline HTML comments
A short comment can stay on one line. A longer editorial note can span several lines as long as the opening and closing markers are present.
Keep the markers easy to spot. A missing `-->` can cause a larger part of the document to be treated as raw HTML or hidden unexpectedly, depending on the renderer.
- Use a complete opening and closing marker.
- Do not rely on comments to disable executable code in another language.
- Preview the final document after changing a multiline comment.
<!-- Replace this screenshot after launch. -->
<!--
Reviewer: confirm the figures in the table.
Remove this note before publishing.
-->Neither note appears as visible page content in a compatible renderer.Hidden from the page does not mean private
A Markdown comment normally stays in the `.md` file. A reader can open the raw file, use a repository's source view, inspect an exported file, or retrieve the original through version history.
Comments are appropriate for harmless editorial context: a fact to verify, a section waiting for review, or a reminder to replace an image. They are not an access-control mechanism.
| Safe editing note | Unsafe content |
|---|---|
| Confirm this date before release | Password or API key |
| Replace the draft diagram | Private customer information |
| Reviewer: check this calculation | Unannounced financial result |
| Keep this heading for the next revision | Anything that must be deleted, not merely hidden |
How comments behave on GitHub
GitHub documents HTML comments as the way to hide content from rendered Markdown. The hidden text still exists in the repository file, and GitHub lets readers switch from the rendered view to the source.
Use comments in README files for contributor reminders only when it is acceptable for every repository reader to see them. In a public repository, assume the raw comment is public.
## Installation
<!-- Keep this command synchronized with package.json. -->
```sh
npm install
```The reminder is omitted from the rendered README; it remains in the README.md source.Obsidian comments are useful but not portable
Obsidian supports `%% comment %%` for inline or block comments. Obsidian hides them outside Editing view, which makes the syntax convenient for personal notes and drafting inside a vault.
The `%%` form is an Obsidian extension. Another Markdown renderer may show the percent signs and the note as ordinary text. Use HTML comments instead when the same file must move between GitHub, a CMS, a static-site generator, and multiple editors.
The proposal is ready. %%Ask Sam to check the budget.%%
%%
This whole block is an editing note.
%%Obsidian hides these comments in Reading view; a generic renderer may display them.Comment markers inside code are examples, not comments
Inline code and fenced code blocks preserve literal characters. Put `<!-- note -->` inside a code block when you want to teach the syntax or show an HTML file; do not expect the Markdown renderer to remove it.
The language inside a fenced block controls highlighting, not whether Markdown comment rules run inside that block.
```html
<!-- This marker is displayed as code. -->
<p>Example</p>
```A visible HTML code block containing the comment marker and paragraph tag.Why a comment may appear or disappear in another renderer
CommonMark defines HTML comments as raw HTML, but a product can still disable raw HTML or sanitize the generated HTML for security. Some systems preserve the comment in generated source; others remove it during conversion or publishing.
A local preview proves only how that preview behaves. Before relying on a comment, test the file in the actual destination: the repository, documentation generator, CMS, note app, or export format that readers will use.
| Observed result | Likely reason | Next check |
|---|---|---|
| Comment hidden in preview | Renderer accepts HTML comments | Inspect the raw Markdown source |
| Markers appear as text | Raw HTML is disabled or escaped | Check the destination's Markdown settings |
| Comment missing from exported HTML | Sanitizer or converter removed it | Inspect both source and exported artifact |
| Content after a comment disappears | Closing marker may be missing | Validate `<!--` and `-->` pairs |
Choose comments according to where the file will live
Portability matters more than convenience when several tools share the same Markdown file. HTML comments are the safer default for a repository or publishing workflow that accepts raw HTML. Platform-specific markers are reasonable when the file is deliberately tied to one application.
- Name the final rendererDecide whether the document will live on GitHub, in Obsidian, in a CMS, or in another publishing system.
- Use the narrowest safe noteKeep comments short, non-sensitive, and directly related to editing the surrounding content.
- Test source and outputCheck the rendered view, raw source, downloaded file, and version history before publishing.
- Delete resolved commentsRemove notes that no longer help the next editor instead of leaving permanent clutter.
The standards behind the behavior
CommonMark specifies HTML comments within raw HTML blocks and inline raw HTML. GitHub and Obsidian then document the behavior of their own renderers and extensions. These references are more reliable than assuming every app implements the same dialect.
Markdown syntax FAQs
What is the syntax for a comment in Markdown?
Markdown has no universal Markdown-only comment marker. Where raw HTML is supported, use `<!-- comment -->` to hide a note from rendered output.
Are Markdown comments private?
No. A comment may be hidden from the rendered page but remain readable in the `.md` source, repository history, downloaded file, or generated artifact. Never place secrets or personal data in it.
Do HTML comments work on GitHub?
Yes. GitHub documents HTML comments for hiding content from rendered Markdown. The text remains in the repository source and should be treated as public in a public repository.
What does `%% comment %%` mean in Markdown?
It is Obsidian-specific comment syntax, not portable core Markdown. Obsidian hides it outside Editing view, while another renderer may display the markers and text.
Can a Markdown comment span several lines?
Yes. An HTML comment can span several lines between `<!--` and `-->`. Preview the document afterward because a missing closing marker can hide or alter more content than intended.
Why is my Markdown comment visible?
The destination may disable raw HTML, escape it as text, or use a different dialect. Confirm the syntax is outside a code block and test it in the final renderer.
Do comment markers work inside a fenced code block?
They remain literal code inside the fence. This is useful for examples, but the marker is not processed as a Markdown or HTML comment there.
Should resolved editing notes stay in the file?
Usually no. Remove a comment after it has served its purpose unless it gives future editors durable, non-sensitive context.
