Add an image to the front matter of a jekyll post

4.5k views Asked by At

When using jekyll how do you add an image to the datatype of the front matter, so it shows up with the title and date within the blogpost list.

1

There are 1 answers

4
dalanz On

Try to put an image path in your front matter.

I mean, all your post like this one:

---
title: My post
description: My description
image: /img/folder/image.jpg
----

bla bla bla

Therefore, you can load an image for every single post. This is an example:

---
layout: default
--- 

{% for post in site.posts %}
<p><h1>{{ post.title }}</h1></p>
<img src="{{ post.image | prepend: site.baseurl }}" alt="{{ post.title }}" title="{{ post.title }}">
{% endfor %}