-
Notifications
You must be signed in to change notification settings - Fork 0
Liquid Extensions
Jekyll uses Liquid to process templates. Along with the standard liquid tags and filters, Jekyll adds a few of its own:
Convert a Time into XML Schema format.
{{ site.time | date_to_xmlschema }}
=> 2008-11-17T13:07:54-08:00
Escape some text for use in XML.
{{ post.content | xml_escape }}
Count the number of words in some text.
{{ post.content | number_of_words }}
=> 1337
Convert an array into a sentence.
{{ page.tags | array_to_sentence_string }}
=> foo, bar, and baz
Convert a Textile-formatted string into HTML, formatted via RedCloth
{{ page.excerpt | textilize }}
If you have small page fragments that you wish to include in multiple places
on your site, you can use the include
tag.
{% include sig.textile %}
Jekyll expects all include files to be placed in an _includes
directory at the root of your source dir. So this will embed the contents of /path/to/proto/site/_includes/sig.textile
into the calling file.
Jekyll has built in support for syntax highlighting of over 100 languages via Pygments. In order to take advantage of this you’ll need to have Pygments installed, and the pygmentize binary must be in your path. When you run Jekyll, make sure you run it with Configuration
To denote a code block that should be highlighted:
{% highlight ruby %} def foo puts 'foo' end {% endhighlight %}
The argument to highlight
is the language identifier. To find the appropriate identifier to use for your favorite language, look for the “short name” on the Lexers page.
There is a second argument to @highlight@called linenos
that is optional. Including the linenos
argument will force the highlighted code to include line numbers. For instance, the following code block would include line numbers next to each line:
{% highlight ruby linenos %} def foo puts 'foo' end {% endhighlight %}
In order for the highlighting to show up, you’ll need to include a highlighting stylesheet. For an example stylesheet you can look at syntax.css. These are the same styles as used by GitHub and you are free to use them for your own site. If you use linenos, you might want to include an additional CSS class definition for lineno
in syntax.css to distinguish the line numbers from the highlighted code.