Chris Brennan
Chris Brennan

Reputation: 191

Jekyll Collection Output True

I'm using siteleaf for my jekyll site. Here's my problem: I created a metadata field called "image" inside siteleaf cms. This will allow the site publisher to add an image. Here's a visual - https://ibb.co/kHcHdG

With out an image the users posts won't show on the site. After creating this metadata field and uploading an image, siteleaf will then create an _uploads folder in my jekyll directory, a folder for all images.

Jekyll ignores folders beginning with an underscore, so I have to input this yaml code inside the config file to fix this. Code Below.

collections:
  uploads:
title: Uploads
  output: true
posts:
  title: posts
  output: true

Inside my _posts folder, I have a markdown file with front matter that looks like this, code below:

---
title: popcorn
date: 2017-11-06 15:33:00 Z
image: "/uploads/15023253524_589c7b137f_k-ab220c.jpg"
layout: post
---

lorum ipsum.

So far, I followed the right directions, I'm not getting any errors in the console or in jekyll. The posts will not show. I've ran into a wall. I've asked on the jekyll and siteleaf forums, no solution.

Here's a link to the repo - https://github.com/pizzapgh/kevins_site

Help would be appreciated so much, thanks.

Upvotes: 0

Views: 920

Answers (2)

Chris Brennan
Chris Brennan

Reputation: 191

Fixed, finally!

The solution: Go inside my index file and change the following code:

original code

{% if post.img %}
<img src={{ "/assets/img/" | prepend: site.baseurl | append: post.img 
}} alt="{{post.title}}" />
{% if post.img %}

new code

{% if post.image %}
<img src={{ post.image | prepend: site.baseurl }} alt="{{post.title}}" />
{% if post.image %}

Upvotes: 1

Skylar
Skylar

Reputation: 1

Thanks for including a link to your repo.

Here's what I did:

$ bundle install
$ bundle exec siteleaf serve

A few warnings show up in the console, but your site is able to build regardless.

I'm able to access your posts now in the web browser just fine, for example: http://localhost:4000/popcorn/

If you were not expecting this URL pattern, you can change your config file. Right now it says:

permalink: ":title/"

For info on customizing permalinks see: https://jekyllrb.com/docs/permalinks/

Upvotes: 0

Related Questions