2
votes

I use github, github-pages, kramdown and jekyll to publish my static sites.

I need to embed html comments that are visible when viewing the source of a page. The reason for this that I want to be able to visually use comments to differentiate between the different parts of raw source html markup. This is doable by using regular html syntax:

<!-- here's my comment -->

The problem I've encountered is that while I serve my jekyll site locally I do see comments in the page source, but once pushed to my github repository the comment isn't visible anymore. However it's still visible in my repo when viewing the raw markdown source file.

The behavior I expect would be seeing my comment in the page source code like I do locally. I've tried kramdown comment syntax:

{::comment}
 here's my comment
{:/comment}

This works but this way I don't see it in the page source at all. Another solution I've tried is the workaround described in this response. It works but it produces an actual html tag and therefore any clear separation between the comment and the other html tags is lost.

The bottom-line is that I want to see the comment when viewing my page source even after pushing my files to my repository.

Is there something I'm missing here or isn't it possible to keep html comments intact while used in conjunction with github-pages?

EDIT: Turns out it was not a markup or Github problem after all. I use a CDN service, this minified the HTML and stripped away HTML comments.

1
If you just add <!-- here's my comment --> in a .yml file it will be available in the source of the html page.marcanuy
Markdown files rendered on the GitHub site will have raw HTML stripped out as a security measure. You would essentially need to request that GitHub disable their security, which it not going to happen.Waylan
Do you have a repository url ?David Jacquel
@Waylan Do you happen to have link or something like that so I could read and learn more about this? My search engine skills seem to fail me at the moment.user7677800
@marcanuy I don't know. The files in question are aren't yaml files though. They are markdown files.user7677800

1 Answers

1
votes

Please check there is no "HTML Minification" running on GitHub which could be actually removing comments while serving for save bandwidth.