Jekyll post not generated
Asked Answered
F

10

115

I am trying to add a new post to my Jekyll site, but I cannot see it on the generated pages when I run jekyll serve.

What are some common reasons for a Jekyll post to not be generated?

Fogbound answered 3/6, 2015 at 15:55 Comment(2)
When using collections folder, put the _post folder in your collections directory. github.com/jekyll/jekyll/issues/6702Cenesthesia
When you change the collections_dir in your config from . to my_col_folder all your posts have to move as well below my_col_folder/_posts jekyllrb.com/docs/configuration/default -> this is such a strange behavior!Pomp
F
270
Fogbound answered 3/6, 2015 at 15:55 Comment(8)
using future:true without any space after : in _config,yml leads to ERR: Configuration file: (INVALID). future: true most be used instead.Nonobedience
Another possible reason is because of forgetting to add the .markdown extension to the filename. I know this because I've just wasted 5 minutes of my life because of it.Kaleb
Thank you so much! Just searched 30 minutes why my post wasn't showing up until I understood that there's a date filter ... (in 15mins it would work "magically"...). Added the future option and everything works as expected. true should be default in my opinion.Jessalin
The same for me: had a post under _drafts promote it to _posts and it disapperead. 30 minutes to understand it: page in _drafts folder doesn't need date in the title, page under _posts need it... Thank you!Libration
When apply future: true you may need to stop and start your Jekyll server for the change to take effect.Garbers
What am I missing. My post here has a colon in the title and it's ok? raw.githubusercontent.com/alexharv074/alexharv074.github.io/… and it appears ok here? alexharv074.github.ioElectrocorticogram
@AlexHarvey Thanks for the comment! This indeed seems to not be a problem anymore. I updated my answer.Fogbound
This is why you should read Jekyll docs before doing a post scheduler like this.Standfast
E
25

You can use jekyll build --verbose to view build process in detail.

Exmaple output:

  Logging at level: debug
Configuration file: /home/fangxing/fffx.github.io/_config.yml
  Logging at level: debug
         Requiring: jekyll-archives
         Requiring: jekyll-livereload
         Requiring: kramdown
            Source: /home/fangxing/fffx.github.io
       Destination: /home/fangxing/fffx.github.io/_site
 Incremental build: enabled
      Generating... 
       EntryFilter: excluded /Gemfile
       EntryFilter: excluded /Gemfile.lock
           Reading: _posts/2018-01-14-new-post.md
           Reading: _posts/2014-01-01-example-content.md
           Reading: _posts/2014-01-02-introducing-lanyon.md
           Reading: _posts/2017-11-21-welcome-to-jekyll.markdown
           Reading: _posts/2018-01-14-boot-android-on-charge.md
           Reading: _posts/2013-12-31-whats-jekyll.md
          Skipping: _posts/2018-01-14-boot-android-on-charge.md has a future date
        Generating: Jekyll::Archives::Archives finished in 0.000122873 seconds.
        Generating: JekyllFeed::Generator finished in 0.000468846 seconds.
        ...

from the log I found jeklly skipped 2018-01-14-boot-android-on-charge.md because it has a future date.

Ewing answered 14/1, 2018 at 14:20 Comment(0)
S
9

One possible reason is that the date specified in the front matter does not contain a time zone offset, in which case it defaults to UTC, not the time zone of the local machine as you might expect. I wasted an hour on this until UTC "caught up" with my current local time zone, BST.

I haven't found a definitive answer to this but I think the date in the front matter must be given in UTC with a timezone offset (which defaults to zero if omitted).

So date: 2018-05-03 12:34:27 is in UTC irrespective of where in the world you are, and irrespective of the timezone setting in _config.yml.

So be careful to specify datetimes like this:

date: 2018-05-03 12:34:27 +0100
Sayce answered 3/5, 2018 at 12:43 Comment(2)
The format date: 2018-05-03 12:34:27 +01:30 also seems to work. Note the additional colon.Leonteen
Wasted 10 mins to realise this was the issue. Thanks!Contemporaneous
C
2

Or it can be browser cache as well if you are looking not in the _site folder but directly on the blog's main page with the list of posts.

Carollcarolle answered 20/2, 2016 at 10:59 Comment(0)
E
2

I have written Rspec tests for my blog that express these rules:

require 'spec_helper'
require 'yaml'

# Documented at https://jekyllrb.com/news/2017/03/02/jekyll-3-4-1-released/
post_regex = %r!^(?:.+/)*(\d{2,4}-\d{1,2}-\d{1,2})-(.*)(\.[^.]+)$!

def date_in_front_matter(date)
  return date if date.is_a?(Date)
  return date.to_date if date.is_a?(Time)
  return Date.parse(date) if date.is_a?(String)
end

describe 'posts' do
  Dir.glob("_posts/*md").each do |file|
    basename = File.basename(file)

    context basename do
      front_matter = YAML.load(File.read(file).split(/---/)[1])

      it 'filename must match documented post regex' do
        expect(basename).to match post_regex
      end

      it 'date in file name same day as date in front matter' do
        date_in_file_name = Date.parse(post_regex.match(basename).captures[0])
        expect(date_in_front_matter(front_matter['date'])).to eq date_in_file_name
      end

      it 'title in front matter should not contain a colon' do
        expect(front_matter['title']).to_not match /:/
      end

      it 'front matter should not have published: false' do
        expect(front_matter['published']).to_not be false
      end
    end
  end
end

This may be of use to others as I was losing a lot of time due to typos in the date etc.

These tests along with the rest of the Rspec config can be seen in context here.

Electrocorticogram answered 11/8, 2018 at 10:31 Comment(0)
U
2

Just to add one more reason, when you move an article from _drafts to _post, you sometimes need to delete the _site for the article to be regenerated.

In my case it often happens that _site will not be entirely deleted before re-generation so the new article won't appear.

Anyway rm -rf _site and bundle exec jekyll serve works :)

Uniformitarian answered 27/5, 2019 at 6:9 Comment(0)
G
1

If you have checked your front matter, and all seems well, and even jekyll build --verbose doesn't reveal anything (in my case, it just acted as if the file didn't exist at all, not even listing it as excluded), check the encoding of your file. Apparently, it needs to be UTF-8 without signature. It it's UTF-8 BOM (or UTF-8 with Signature as some text editors call it), then it will be silently ignored. To make matters worse, some editors will display both types as just UTF-8, making the difference even harder to spot.

Gonta answered 8/11, 2019 at 14:35 Comment(0)
G
1

If you are unable to track the file in --verbose and if the file is silently ignored then try removing collections_dir in the config.yml file. That solved the issue for me.

Gland answered 2/1, 2020 at 14:42 Comment(0)
C
0

My post also did not appear an the error was, that in my name I used a dot, e.g. 2017-10-18-test.2.md.
This is not accepted, you have to use 2017-10-18-test2.md.

Character answered 18/10, 2017 at 20:14 Comment(0)
E
0

In my case I had enabled incremental build which caused this issue, make sure to check it.

Exhaust answered 13/7, 2023 at 18:25 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewIntrogression
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Confess

© 2022 - 2024 — McMap. All rights reserved.