Comment out an include statement inside an HTML file using Jekyll
Asked Answered
C

4

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 %}           
Cropdusting answered 16/1, 2015 at 1:0 Comment(0)
U
121
{% comment %}
{% include navbar.html %}
{% endcomment %}
Unwashed answered 16/1, 2015 at 1:10 Comment(0)
D
24

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

Dubbing answered 1/11, 2016 at 20:29 Comment(0)
E
2

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 %}
Engvall answered 24/2, 2023 at 7:46 Comment(0)
P
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

Pancratium answered 13/8, 2023 at 18:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.