What does {% capture var%} do in jekyll?

What does {% capture var%} do in jekyll?

Can I, for example, in the .md file do:

{% capture head %} I am the head {% endcapture %} 

and then in the .html file do:

 {{head}} 

Am I using capture correctly? Unfortunately, I could not find the capture documentation.

+5
source share
1 answer

capture allows you to assign text to the name of a variable. Later, referring to this variable, you can display this text.

In the above example, head is the name of the variable. So, you say, put all the text between the capture tags of the open and close in a variable called head .

Then in {{head}} you say you want to delete the contents of this variable on the page. There is nothing special about the name head , and you can rename it to something completely different.

More information on capture can be found on this page Liquid for Designers

+6
source

All Articles