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?
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.
Front matter is a snippet of YAML placed between two triple-dashed lines at the start of a file. You can use front matter to set variables for the page: --- my_number: 5 --- You can call front matter variables in Liquid using the page variable.
Frontmatter is a way to identify metadata in Markdown files. Metadata can literally be anything you want it to be, but often it's used for data elements your page needs and you don't want to show directly. Some examples of common metadata are: Title of the post. Description for SEO purposes.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With