Search code examples
jekyllliquid

Jeykyll, what is the difference between {%- do-someting -%} and {% do-someting %}?


In the Jeykll in documentation to Liquid I found the notation {% … %} but in some plugins or example code snippets I saw also {%- … -%} (with a dash after and before percentage symbol). What is the right usage?

  • a) {%- include header.html -%}
  • b) {% include header.html %}

Or is it even dependent from the command / option / function which I am using inside the block?


Solution

  • The dashes give you the ability to control the whitespace around your tags. This often isn’t necessary for HTML generation, but can come in handy for certain uses in pre-formatted text. Or, if you are just picky about what your final HTML looks like ;)

    Check out the docs here: https://shopify.github.io/liquid/basics/whitespace/