Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to comment out stuff in Markdown on GitHub?

Comments in GitHub flavour of Markdown

As answers to this Stack Overflow question reveal, using <!--- and ---> or <!-- and --> works (view source by clicking "Raw"):

Inline comments

How about commenting out <!--- just ---> a part of one line?

If you know of a way, please show me how by cloning this Gist, or commenting below!

Update 2019

As several commenters pointed out, for inline commenting <!-- a normal html comment --> now works.

You can't see this:

Btw, wow, I created this gist in 2014 and only now became aware of the discussion and that it's the top Google hit for markdown comments github. 👍

@barakb

This comment has been minimized.

Copy link

@barakb barakb commented Aug 9, 2016

You are right

@steffengrahl

This comment has been minimized.

Copy link

@steffengrahl steffengrahl commented Mar 5, 2017

Is it just me or do inline comments work now? Cant see the <!---just--->` in the second paragraph.

@JamesDonnelly

This comment has been minimized.

Copy link

@JamesDonnelly JamesDonnelly commented May 24, 2017

This is the top result on Google for comments within markdown on GitHub and I can confirm that this now works.

@thefzsalam

This comment has been minimized.

Copy link

@thefzsalam thefzsalam commented May 30, 2017

I can still see the <!---just---> in the second paragraph.
EDIT: I accidentally figured out that using two '-' hyphens like <!-- instead of three <!--- works.
Here's a comment - - see raw. But this doesn't work <!--- This isn't commented out --->.
2017-05-30-175951_928x249_scrot
2017-05-30-180001_1017x294_scrot

@utkarsh2102

This comment has been minimized.

Copy link

@utkarsh2102 utkarsh2102 commented Jun 27, 2018

Check?

P.S. <!--- --> is working :)

@pretzelhands

This comment has been minimized.

Copy link

@pretzelhands pretzelhands commented Sep 4, 2018

Let's see if this works.

@kerimeredith

This comment has been minimized.

Copy link

@kerimeredith kerimeredith commented Sep 7, 2018

https://github.github.com/gfm/ has this:
"An HTML comment consists of <!-- + text + -->, where text does not start with > or ->, does not end with -, and does not contain --. (See the HTML5 spec.)"

I had a URL that I wanted to comment out but could not figure out how to do that. (http://foo-bar.s3-website-us-bla-1.amazonaws.com/#)

@ianrodrigues

This comment has been minimized.

Copy link

@ianrodrigues ianrodrigues commented Sep 11, 2018

No description provided.

@element6

This comment has been minimized.

Copy link

@element6 element6 commented Nov 9, 2018

You can't see this:

nor this:

@Simonkyverde88

This comment has been minimized.

Copy link

@Simonkyverde88 Simonkyverde88 commented Jul 23, 2019

I believe a comment is written <!--Text--> and not <!---Text--->. The second will just cause trouble and obvious errors.

@jonikarppinen

This comment has been minimized.

Copy link
Owner Author

@jonikarppinen jonikarppinen commented Dec 3, 2019

Idea for triple dash came from https://stackoverflow.com/a/4829998. Back when this gist was originally written, the normal html comment didn't work at least for inline comments.

Anyway, gist updated now, thanks for all the comments! 😏

@matb33

This comment has been minimized.

Copy link

@matb33 matb33 commented Jan 25, 2020

Note that GitHub's search won't index what's in these comments.

@kublermdk

This comment has been minimized.

Copy link

@kublermdk kublermdk commented Feb 11, 2020

I thought for a moment that comments are now shown, but I just checked and they aren't.

There's two comments above, in double and triple hyphens and you shouldn't be able to see them.

@rowe-morehouse

This comment has been minimized.

Copy link

@rowe-morehouse rowe-morehouse commented Sep 11, 2020

Try this:

[//]: # (This is a comment.)
[//]: # (This is a comment on a new line.)

Make sure add a double space after each comment line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.