Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including markdown inside yaml front-matter

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?

like image 545
Bernard Avatar asked Feb 15 '14 05:02

Bernard


People also ask

Does YAML support Markdown?

YAML can include multiple, markdown-style paragraphs by using a pipe character, dropping down a line, and indenting one level.

What is front matter Markdown?

The Front Matter extension tries to make it easy to manage your Markdown pages/content. Within a Markdown page, we allow you to fold the file's Front Matter to be less distracting when writing. Also, do we highlight the Front Matter content to create a visual difference between content and metadata.

How do you use YAML front matter?

YAML frontmatters can be defined at the beginning of a file, by starting on the first line with three dashes ( --- ) and ending the frontmatter either with three dashes or three dots (the former variant is more common). They contain valid YAML and can be used to define arbitrary variables.

What is YAML front matter PHP?

A to the point front matter parser. Front matter is metadata written in yaml, located at the top of a file wrapped in --- 's. --- title: Example --- Lorem ipsum. use Spatie\YamlFrontMatter\YamlFrontMatter; $object = YamlFrontMatter::parse(file_get_contents(__DIR__.


1 Answers

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/

like image 125
Madhur Ahuja Avatar answered Sep 21 '22 08:09

Madhur Ahuja