Specifying multiline front matter

I’m in the process of porting a theme from Hugo to Jekyll and in Hugo there is this idea called “shortcodes” or small snippets of html that can be included as a variable in a layout.

I don’t see where Jekyll has this, so I figured the best substitute was to just make an include out of it and include it where needed.

So far so good until I needed to include it if a variable is defined in the page front matter.

The variable content is multi-line and Jekyll doesn’t like this and complains. I haven’t found the magic sauce to allow a multi-line variable in a single front matter variable.

In _config.yml there is a syntax for this very thing, but it isn’t supported from front matter.

Once I figure out how to use the multi-line variable the if var exists then include that part should work just fine.

Thanks for your attention

YAML supports multiline content, see this SO thread:

Now if you’re trying to do a push multiline content to an include parameter, that might not be supported without using Liquid assign or capture first.

I don’t think this helps much because when I add front matter to a page like so:


varname: - >
This is my multiline yaml frontmatter
here.


I get an error like this:

YAML Exception reading /path/to/file.md: (): block sequence entries are not allowed in this context at line X column Y.

If I put the text all on one line, it works just fine.

Wondering what I am doing wrong, as this appears to work fine from _config.yml