Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In jekyll, how to parse a variable as markdown instead of printing it as is?

Tags:

jekyll

Given the following file:

_data
  slides.yml

which includes

- title: Slide one
  desc: |
    welcome to the slideshow
    This is an open-source slideshow, built with [deck.js](https://github.com/imakewebthings/deck.js), GitHub and [Jekyll](http://jekyllrb.com).

- title: Slide two
  desc: |
    Second slide with bullet points
     * Hello world
     * This is a slideshow

In my index.html I have

{% for slide in site.data.slides %}
  <section class="slide">
    <h2>{{ slide.title }}</h2>
    {{ slide.desc }}
  </section>
{% endfor %}

How can I get Jekyll to interpret {{ slide.desc }} as markdown? Does something like this exist:

...
{{ slide.desc AS markdown }}
...

Thanks!

Albert

like image 752
alberto56 Avatar asked Nov 02 '14 03:11

alberto56


People also ask

How do you link pages on Jekyll?

Jekyll also has the {% link %} tag, which can be used to link to a post, page, collection document, or file. The big difference between link and post_url is that the link tag requires the file's full path e.g., directory and extension.

What is Jekyll HTML?

Jekyll is a static site generator. It takes text written in your favorite markup language and uses layouts to create a static website. You can tweak the site's look and feel, URLs, the data displayed on the page, and more.


1 Answers

Found the answer!

...
{{ slide.desc | markdownify }}
...

Here is the reference.

like image 77
alberto56 Avatar answered Sep 17 '22 13:09

alberto56