Home /

Notes to self /

Jekyll tips & tricks

Jekyll tips & tricks

It's a 3 minute read

Here are a few little helpers for you to use as you build up your site.

Reading Time

Add the reading time to a post, like they do here on medium! Paste the code below inside a post layout. If you are using within a layout file change content to page.content.

{% capture words %}
  {{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains "-" %}
  {% assign minutes = words | plus: 180 | divided_by: 180 %}
    {{ minutes }}
  {% if minutes == 1 %}
    {{ " minute to read." }}
  {% else %}
    {{ " minutes to read." }}
  {% endif %}
{% endunless %}

Dates

Month, day, year

 {{ page.date | date: "%B %-d, %Y" }} 

Current year

 {{ site.time | date: "%Y" }} 

A link is presented in markdown as [User Friendly Text](http://domain.com/). This will open link in the same page/window/tab. To open a link in a new tab we need to add {:target="_blank"} right after the href syntax or alternatively use the html <a> tag.

Filters

Output markup can take filters, which modify the result of the output statement. You can invoke filters by following the output statement’s main expression with:

Optionally, a colon (:) and a comma-separated list of additional parameters to the filter. Each additional parameter must be a valid expression, and each filter pre-defines the parameters it accepts and the order in which they must be passed.

Filters can be chained together by adding additional filter statements (starting with another pipe character). The output of the previous filter will be the input for the next one.

Hello {{ 'alan' | upcase }}
#=> Hello ALAN

Hello alan has {{ 'alan' | size }} letters!
#=> Hello alan has 4 letters!

Hello {{ '*alan*' | textilize | upcase }}
#=> Hello *ALAN*

It's the {{ 'now' | date: "%d %h, %Y " }}
#=> It's the 16 Mar, 2023 

Privacy

© 2023 Alan Reid