rasmer
rasmer

Reputation: 33

List of variables in jekyll post

1 ---
2 layout: post
3 title: "Welcome to Jekyll!"
4 date: 2018-06-03 11:57:53 +0300
5 categories: jekyll update
5a somevar: sw1 sw2 sw3 sw4
6 ---

in "standart" variables of default post i add somevar (line 5a)
i need in result:

SOME VARIABLES:
- sw1
- sw2
- sw3
- sw4

p.s. the quantity of "swX" can be a miscellaneous

Upvotes: 2

Views: 904

Answers (1)

Mr. Hugo
Mr. Hugo

Reputation: 12592

Create an array (in your .md file), like this:

---
layout: post
title: "Welcome to Jekyll!"
date: 2018-06-03 11:57:53 +0300
categories: jekyll update
somevar: 
  - sw1 
  - sw2 
  - sw3 
  - sw4
--- 

Output the front matter (in your layout) like this:

{% for item in page.somevar %}
  {{ item }}
{% endfor %}

Upvotes: 5

Related Questions