Including markdown inside yaml front-matter

Bernard picture Bernard · Feb 15, 2014 · Viewed 8.1k times · Source

One of my web pages needs to include rows of items (image, title, description). The description must accept markdown. I haven't found any way to do this in Jekyll without plugins or creating multiple files, one for each item.

Another requirement is that the site be built by Github Pages. ie: no Jekyll plugins, Redcarpet markdown.

Ideally, I would have liked to create a Jekyll data file (_data/products.yml) which contains a structure similar to below. Note that Description contains markdown list and formatting.

- Name: Company A
  Year: 2005
  Description: >
    I was responsible for the following:
    - Review of contracts
    - Hiring
    - Accounting

- Name: Company B
  Year: 2010
  Description: >
    My role included **supervising** the marketing team and leading **publicity**.

Another option I saw was to use Front-matter with the above info. It is slightly more cumbersome since it ties the data with a particular page (eg: work-experience.md).

I've tried various variations on the above but the formatting is never transformed into HTML. How can this be handled?

Answer

Madhur Ahuja picture Madhur Ahuja · Feb 17, 2014

If you do not wish to use Plugins, I believe the best bet is to have it in _data although not sure if it would be valid YAML or even a valid YAML is a requirement for _data content.

Have you tried using markdownify function such as

{{ site.data.products.description | markdownify }}

http://jekyllrb.com/docs/templates/