I’ve been using Jekyll since a couple of years and this is my first time here. So far, I’ve been able to manage all issues (and even to write some Ruby plugins) but today I’m facing a wall.
I’ve tried to upgrade to Jekyll 4.2.0 from 4.1.1. With the new version, the index page is empty. The list of posts written by a specific author is empty. Also, a list I generate by myself through a specific _data file is also empty.
I gather the index page is still blank with --safe? Are any pages built?
Another source of problems might be Gemfile.lock. You could try deleting it and running bundle install again. Did you upgrade by edit the Gemfile and running bundle update?
Another sanity check is to try creating a test site (outside of your site). The following should result in the standard “Welcome to Jekyll” site using the Minima theme. If not, then something may be wrong with Ruby or the Jekyll gems:
jekyll -v
jekyll new test
cd test
bundle exec jekyll serve
I don’t know if --safe helps as it will disable any plugins that don’t have safe: true. And you need your plugin to not be disabled.
I would try using {{ value | inspect }} or some other low level debugging maybe logging in your plugin to see where the data is set and then where it becomes blank.
Look at the raw HTML too in the output. Maybe it is there but just no visible
You can also do jekyll build --verbose --trace for detailed logs and any error traceback
See also 4.2 changes
Can you confirm your problem is both on your local machine as well as your remote site? If the problem is not in common then it looks like an environment setup issue
Also you can try a fresh Jekyll new site as recommended up, if you set it to Jekyll 4 once it is created. You’ll lack your layouts and plugins though. You could start copying things to that new project incrementally and see at what point the site becomes blank. Maybe you can skip the layouts and plugins and just try and render a small liquid snippet that handles your list, then you know it works or doesn’t work in Jekyll 4.2 regardless of your larger custom code setup
I’ve some errors with verbose and trace but they don’t seem to be related
Error reading file /Users/nico/projects/private/nfrankel.gitlab.io/me/page/3/index.html: No such file or directory @ rb_sysopen - /Users/nico/projects/private/nfrankel.gitlab.io/me/page/3/index.html
Error reading file /Users/nico/projects/private/nfrankel.gitlab.io/me/page/3/index.html: No such file or directory @ rb_sysopen - /Users/nico/projects/private/nfrankel.gitlab.io/me/page/3/index.html
If your plugins are something the community could use, consider sharing those as public github repos. You don’t have to upload to rubygems - one can install a plugin gem from a github URL.
If you don’t want to make it installable, you can also just make a repo with a ruby script in the root and instructions to copy it to plugins folder.
I managed to find the problems but I’ve no clue why the minor update broke the working plugins.
I used module Jekyll. For my defense, I’m not a Ruby developer, but yes, when I read it, I realized it’s bad
I didn’t use this magic snippet:
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, type, key)
end
By fixing both, it now works. I was thinking about writing a blog post about it, but since I cannot explain anything…
As for the publishing, those are very specific. One plugin is to generate pages out of YAML data, the other is to generate pages displaying pages per author. And probably you don’t want to reuse any of my Ruby code
Here’s the code of the first one in case you find it interesting.
Oh I see that “magic” bit is covered at the bottom of the tutorial I linked to
# Look up front matter defaults scoped to type `categories`, if given key
# doesn't exist in the `data` hash.
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, :categories, key)
end
@nfrankel Jekyll 4.2.0 includes minor optimizations to the class Jekyll::Page and module Jekyll::Convertible which may have broken your previously working plugins.
My apologies for breaking the SemVer contract unknowingly.
Technically, the class and module mentioned above has good test coverage. But looks like the coverage isn’t enough.
If you can provide the --trace output, perhaps that may shed some light on what exactly is the cause behind the break.
In the end, since you managed to get things working again, what is the final outcome?
Did Jekyll 4.2.0 induce you to improve your plugin(s) or was it the opposite effect?
@nfrankel Let me try to clarify the comment for you.
When someone tries to access the value assigned to a given key in a Ruby Hash, Ruby does two things:
if the given key exists, then the value pointed to by the key is returned.
if the key doesn’t exist, then nil is returned.
However, when the Hash under consideration has a default_proc attribute defined, then instead of simply returning nil for non-existing keys, the default_proc is executed and result of that is returned as the value.
Therefore, if a Jekyll Page’s @data hash doesn’t have the given key defined, Jekyll simply looks into the configured front matter defaults if the key is defined there and returns either nil or the value set by the user.