28

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?

Bernard
  • 16,149
  • 12
  • 63
  • 66

1 Answers1

43

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/

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • Yes, the markdownify filter works perfectly. There is no problem putting markdown as value for some YAML fields. I've been able to push to Github Pages and everything shows fine. Thanks. – Bernard Feb 17 '14 at 10:43
  • Awesome advice, had never seen "markdownify" until now, works like a charm. – clark Feb 27 '15 at 23:58
  • Hi! Can you please tell me how can I use this with assemble.io? – MeV Jul 17 '15 at 13:06