62

Is there a way to comment out an include statement inside an HTML file using Jekyll?

For example I have this inside one of my HTML files that I'd like to temporarily comment out. Standard HTML comment doesn't seem to work.

{% include navbar.html %}           
Amit
  • 765
  • 1
  • 5
  • 9

4 Answers4

118
{% comment %}
{% include navbar.html %}
{% endcomment %}
David Jacquel
  • 51,670
  • 6
  • 121
  • 147
22

Jekyll uses the Liquid templating system. So whatever works for Liquid works for Jekyll.

{% comment %}
this is commented out
{% endcomment %}

https://shopify.github.io/liquid/tags/template/#comment

mccambridge
  • 983
  • 7
  • 16
1

mccambridge posted the correct solution. The one posted by David Jacquel does not work in Jekyll. In alternative you can add a space between the bracket { and the percentage simbol % like shown below:

{% comment %}
{ % include navbar.html % }
{% endcomment %}
Goemon Code
  • 73
  • 1
  • 10
0

since jekyll is used inside of html i think it's better to do it this way

  1. make a space between the brackets and percent sign
  2. wrap it in an html comment
<div>
    <!-- { % for i in (1..100) % } -->
    {% for post in site.posts %}
        <a href="{{post.url}}"> {{post.title}}</a>
    {% endfor %}
    <!-- { % endfor % } -->
    
</div>

the above code is a very common use case for me where i want to simulate a lot of posts to debug my ui

cabiste
  • 97
  • 1
  • 8