Jekyll: blog post ignored - how to debug? - blogs

I am trying to set up a blog on github.io using jekyll (site, source)
My problem is that my article in the _posts folder semms to be ignored. I would like to debug the site generation.
I have seen this advice to debug jekyll, but so far I did not understood what is missing.
Can I see if jekyll consider my file or if it is ignored?

In your files names replace underscore by hyphen.
wrong : 2014-11-01_part_of_it.md
good : 2014-11-01-part-of-it.md

the article/post needs a publish date in the front matter
---
date: 2014-11-01 08:57:00 GMT
---

Also keep in mind that your post won't be generated if the publishing date (including the daylight saving time, in my case) is in the future.
date: 2018-07-18 18:00:00 +0100
Reading: _posts/2018-07-18-no-more-ssh-login.markdown
Skipping: _posts/2018-07-18-no-more-ssh-login.markdown has a future date
Had to run bundle exec jekyll serve --verbose to realize it.

Related

github pages ignoring 2022 dates in liquid {{ page.date }}?? fine in local host

Using Jekyll to build a site, I have discrepancies between my local build and what GitHub pages renders.
I have a .html layout that uses the date property of the page for the title:
<h1>Meeting notes - {{ page.date | date_to_string }}</h1>
and the date is obtained thanks to the page's name YYYY-MM-DD-notes.html.
I then use a for loop to parse through all the meetings I have in site.meetings and display all meeting notes after one another in a meetings.html page.
My last two files are called: 2021-12-07-notes.html and 2022-01-18-notes.html so the first two titles in my meetings page should be:
Meeting notes - 18 Jan 2022
Meeting notes - 07 Dec 2021
Which is indeed what I get in my local build (along with all the previous ones, first meeting being in 2019).
But what GitHub pages renders is:
Meeting notes -
Meeting notes - 07 Dec 2021
As if he couldn't 'see' the 2022 date. Still working fine with all previous dates btw and again, on the local build.
Could someone explain this weird behavior?
Ok this was simply because I didn't have the right file name.
The file was actually called 2022-01-18_notes.md and not 2022-01-18-notes.md which made GitHub pages not recognise the date. Apparently my local jekyll is a bit more tolerant.

Fail build if two posts resolve to the same permalink in Jekyll

In my Jekyll site I have a permalink structure like this in _config.yml:
permalink: /blog/:title:output_ext
And I have two posts (in _posts) that resolve to the same permalink silently, for example:
2020-10-15-my-post.md
2020-10-16-my-post.md
Only one is written to _site/blog/my-post.html.
Is there a way to halt the building of the site, and throw an error, if two posts resolve to the same permalink (and then, one post overwriting the other)?
The Jekyll CLI has a command called doctor that outputs any deprecation or configuration issues with your site and, among other things, it detects when two posts resolve to the same permalink.
You can run it similarly to how you build your site today:
bundle exec jekyll doctor
In the example you gave in your question, jekyll doctor will show you an error message about a conflict between two pages, similar to this:
Configuration file: /your-website/_config.yml
Jekyll Feed: Generating feed for posts
Conflict: The URL '/your-website/_site/blog/my-post.html' is the destination
for the following pages: /your-website/_posts/2020-10-15-my-post.md,
/your-website/_posts/2020-10-16-my-post.md
When jekyll doctor finds a conflict like the above, its exit code will be non-zero which you can use to fail the build.

Jekyll Blog not updating / showing new posts

After I read through all the questions I found here, I still don't get my blog Atmochrom.com running
You can find my repository right here: https://github.com/MarcLeyendecker/marcleyendecker.github.io
I did not change anything. Actually I always duplicate my latest post, edit the .markdown file and push it to the repository. Working for over a year now this way, now it just fails to show the updated site.
Any ideas what I could do?
I already...
checked the config
checked the CNAME
checked the index
Really hope you can help me!
Marc, just double check ...
your post markdown is clean
there are no untracked files when you push to git
This post can help What are some common reasons for a Jekyll post to not be generated?
This tip helped future: true

How to know when GitHub Pages finished generating Jekyll?

I have a complex Jekyll website. Every change can take a few minutes to generate.
On my local machine I can see the progress that tells me when the re-generation finished.
However on GitHub Pages (Enterprise) how do I know if what I am looking at is the latest version or if it is still generating?
I was thinking maybe Jekyll could print a timestamp somewhere when generating?
You can use <p>Page version : {{ site.time | date: '%B %d, %Y - %H:%M:%S %Z'}}</p> in you footer to print datetime on each page.
Don't forget to set your timezone variable in configuration.

Jekyll post not generated

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?
The post is not placed in the _posts directory.
When you change the collections_dir in your config from . (default) to my_col_folder all your posts have to move as well below my_col_folder/_posts jekyll defaults
The post has incorrect title. Posts should be named YEAR-MONTH-DAY-title.MARKUP (Note the MARKUP extension, which is usually .md or .markdown)
The post's date is in the future. You can make the post visible by setting future: true in _config.yml (documentation)
The post has published: false in its front matter. Set it to true.
The title contains a : character. Replace it with &#58. Works in jekyll 3.8.3 (and probably in other 'recent' releases).
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.
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
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.
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.
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 :)
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.
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.
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.