53
votes

I'm trying to implement a service catalog in Jekyll, in which each of 20 or 30 pages will contain a 7x2 table. The left column will hold labels, e.g. Overview, Available To, etc, while the right column will hold between one line and several paragraphs of text. I was hoping to characterize the right column with Liquid variables, e.g. {overview}, {availableTo}

I've noticed that the YAML seems to be very picky about line breaks, and accordingly I've had to input these paragraphs and their markup on one line which can go on for several screen-widths. This is a problem because it's annoying, and also because I'd like these front-matters to be editable by technical but non-webdev users. Is there a way to have the front matter tolerate breaks?

Alternatively, is there a way that I could populate this table with the {content} section, without having to recode the table into it each time?

1

1 Answers

86
votes

Yaml syntax for multi-line strings is this one:

body: |
  This is a multi-line string.
  "special" metacharacters may
  appear here. The extent of this string is
  indicated by indentation. 

Notice that the first line must be an space followed by the | character and a new line. Then you must indent the text one level more than its parent.

Consequently, you can create one item this way:

item1:
  overview: |
    overview text
    more overview text
  available_to: 2012-01-01
  foo: |
    foo text
    more foo text

It seems to me that you also want to arrange your items in order. You can employ a yaml list for that:

catalog:
  - id: item 1
    overview: |
      overview text
      more overview text
    available_to: 2012-01-01
    foo: |
      foo text
      more foo text
    ...
  - id: item2
    overview: <similar to above>

I hope this helps!