user6227558
user6227558

Reputation: 31

Add an image to the front matter of a jekyll post

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.

Upvotes: 2

Views: 4765

Answers (1)

dalanz
dalanz

Reputation: 111

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 %}

Upvotes: 8

Related Questions