1
votes

Recently, I decided to start my Blog on Github Pages. I forked Jekyll-Now and pulled the code into my local environment.

Now I am running jekyll serve but it is not reading the posts in the _posts folder!.

It seems that the site.posts variable in index.html couldn't be read. If I output the variable or inspect it as : {{ site.posts | inspect }} then it is empty.

The posts names are within the correct format YYYY-MM-DD-TITLE.md If I run jekyll serve inside the _posts folder, then I will get an IndexOf page with all the posts listed without any problem.

The content of _config.yml :

# Name of your site (displayed in the header)
name: My name

# Short bio or description (displayed in the header)
description: Blog on various topics

# URL of your avatar or profile pic (you could use your GitHub profile pic)
# avatar: https://raw.githubusercontent.com/barryclark/jekyll-now/master/images/jekyll-logo.png

# Includes an icon in the footer for each username you enter
footer-links:
  github: motleis/blog

baseurl: ""
permalink: /:title/

# The release of Jekyll Now that you're using
version: v3.4.0

# Jekyll 3 now only supports Kramdown for Markdown
kramdown:
  # Use GitHub flavored markdown, including triple backtick fenced code blocks
  input: GFM
  # Jekyll 3 and GitHub Pages now only support rouge for syntax highlighting
  syntax_highlighter: rouge
  syntax_highlighter_opts:
    # Use existing pygments syntax highlighting css
    css_class: 'highlight'

# Set the Sass partials directory, as we're using @imports
sass:
  style: :expanded # You might prefer to minify using :compressed

# Use the following plug-ins
gems:
  - jekyll-sitemap # Create a sitemap using the official Jekyll sitemap gem
  - jekyll-feed # Create an Atom feed using the official Jekyll feed gem

# Exclude these files from your production _site
exclude:
  - Gemfile
  - Gemfile.lock
  - LICENSE
  - README.md
  - CNAME

Under _posts: I have only simple sample file : 2014-3-3-Hello-World.md

---
layout: post
title: You're up and running!
---

Just a single line that should be displayed! 

And here goes the content of index.html, where the posts should be listed:

site.posts : {{ site.posts }}
My posts:
<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
      {{ post.excerpt }}
    </li>
  {% endfor %}
</ul>

The result is :

site.posts :
My Posts:

As you can see site.posts is empty!

What is your suggestions to debug this issue?

I am running jeykll-3.4.0

1
Post the post you located in the _posts folder and its filename. Also _config.yml.marcanuy
Thanks @marcanuy for your comment and for editing the markups in my question. I just edited the post and hope it is more clearmtleis
Seems to be fine, it should work with jekyll serve at the root folder (i.e. the folder that contains _config.yml)marcanuy
Indeed, I am running jekyll serve at the root folder where the _config.yml and _posts folder are located. Index.html is also located there, and it seems to be compiled fine into _site folder. If I edit the index.html with a static content, it will be built fine. The problem is that the variables are not accessed for some reason.mtleis
The filename was it: YYYY-MM-DD-TITLE.md is different than 2014-3-3-Hello-World.mdmarcanuy

1 Answers

3
votes

Updated Answer:

Check that your posts are in YYYY-MM-DD-title.MARKUP, i.e. 2017-01-01-title.md style, with 0 for padding.

Under "Creating Post Files" in "Writing Posts" on Jekyll's documentation page:

To create a new post, all you need to do is create a file in the _posts directory. How you name files in this folder is important. Jekyll requires blog post files to be named according to the following format:

YEAR-MONTH-DAY-title.MARKUP

Where YEAR is a four-digit number, MONTH and DAY are both two-digit numbers, and MARKUP is the file extension representing the format used in the file. For example, the following are examples of valid post filenames:

2011-12-31-new-years-eve-is-awesome.md 2012-09-12-how-to-write-a-blog.md


Former Answer:

Is your _posts folder located in your website's root directory?

My main suggestion otherwise is to create a layout (in the layouts folder) specifically for showing your index (so make a normal webpage and copy and paste the current non-frontmatter content of your index.md file inside). It's my understanding that if it's not Liquid or Markdown, your code is shown as is, and not read / processed for building the website. Even if you have an entirely empty bottom half to your index.md page, to my understanding it should show your posts.