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?

aronisstav
  • 7,755
  • 5
  • 23
  • 48
  • 1
    When using collections folder, put the _post folder in your collections directory. https://github.com/jekyll/jekyll/issues/6702 – MethodMan Aug 15 '22 at 18:40
  • 1
    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` https://jekyllrb.com/docs/configuration/default/ -> this is such a strange behavior! – KargWare Sep 23 '22 at 06:52

10 Answers10

263
KargWare
  • 1,746
  • 3
  • 22
  • 35
aronisstav
  • 7,755
  • 5
  • 23
  • 48
  • 2
    using `future:true` without any space after `:` in `_config,yml` leads to ERR: Configuration file: (INVALID). `future: true` most be used instead. – yaitloutou Jan 23 '17 at 02:42
  • 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. – H2ONOCK Mar 16 '17 at 09:58
  • 1
    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. – Matthias Kleine Jul 02 '17 at 21:43
  • 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! – BAD_SEED Aug 21 '17 at 13:17
  • When apply `future: true` you may need to stop and start your Jekyll server for the change to take effect. – Kamran Aug 21 '17 at 17:36
  • 1
    What am I missing. My post here has a colon in the title and it's ok? https://raw.githubusercontent.com/alexharv074/alexharv074.github.io/master/_posts/2016-05-08-setting-up-puppet-module-testing-from-scratch-part-i-puppet-syntax-puppet-lint-and-rspec-puppet.md and it appears ok here? https://alexharv074.github.io – Alex Harvey Aug 11 '18 at 10:22
  • 1
    @AlexHarvey Thanks for the comment! This indeed seems to not be a problem anymore. I updated my answer. – aronisstav Aug 12 '18 at 07:43
  • This is why you should read Jekyll docs before doing a post scheduler like [this](https://github.com/uta-org/jekyll-scheduler). – z3nth10n Mar 31 '19 at 14:31
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.

Adam Matan
  • 128,757
  • 147
  • 397
  • 562
Fangxing
  • 5,716
  • 2
  • 49
  • 53
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
starfry
  • 9,273
  • 7
  • 66
  • 96
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.

R.Brown
  • 31
  • 3
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.

Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
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 :)

Tibo
  • 621
  • 1
  • 8
  • 24
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.

Kols
  • 3,641
  • 2
  • 34
  • 42
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.

J_F
  • 9,956
  • 2
  • 31
  • 55
0

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.

Dániel Kis-Nagy
  • 2,255
  • 2
  • 18
  • 19
0

it can also be because the incremental build is true, make sure to check it.

a009a
  • 1
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34686814) – user12256545 Jul 18 '23 at 16:27
  • 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](/help/how-to-answer). – Community Jul 21 '23 at 11:31