Jekyll 4.2.0 doesn't seem to get lists

Hello folks,

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.

Any hint would be appreciated!

PS: I’m not a Ruby developer

You might try running a safe build (bundle exec jekyll --safe serve) to see if the problem is due to plugins.

1 Like

Yes, there’s an error:

`unknown_tag': Liquid syntax error (line 10): Unknown tag 'focus_block' (Liquid::SyntaxError)

But it’s handled by one of the plugin I wrote myself :sweat_smile:

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
1 Like

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

Yes agree with above.

Run bundle update to make sure you have Jekyll 4.2 locally

And make sure you are not using Ruby 3. Stay with 2.7

A link to your repo and site would help.

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 run bundle update and that’s the reason I’ve upgraded to 4.2 :sweat_smile:
  • I’m using Ruby 2.7
  • Repo is private sorry…

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 

@chuckhoupt Great idea to start a new site. It does indeed work…

Now I’m trying to remove the plugins one by one but no luck so far

Thanks for your help. I’ve pinpointed the issue down to one of my own plugin and even precisely to the following lines:

site.pages << CurrentTalkPage.new(site, site.source, current_year, year, events_by_year)
site.pages << TalkPage.new(site, site.source, current_year, year, events_by_year)

Now I know where to look :eyes:

1 Like

Great to hear you figured it out.

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.

Or even as a gist.

I managed to find the problems but I’ve no clue why the minor update broke the working plugins.

  1. I used module Jekyll. For my defense, I’m not a Ruby developer, but yes, when I read it, I realized it’s bad

  2. 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 :sweat_smile:

Here’s the code of the first one in case you find it interesting.

Regarding your changes, it would be nice have some clarity for others working on plugins.

  1. Is it correct to say changing the outer line from module Jekyll to module SpeakingPagePlugin fixed it?
  2. Was it necessary to add (or remove?) that default_proc snippet in some or all your plugins?

Thanks for sharing. Yes that does look specific to your needs.

For the interest of anyone else into plugins, there are two generator examples here.

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

Oh I see that “magic” bit is covered at the bottom of the tutorial I linked to

Yep, but the comment is not enough for me to understand exactly what it does :sweat_smile:

Regarding your changes, it would be nice have some clarity for others working on plugins.

  1. Is it correct to say changing the outer line from module Jekyll to module SpeakingPagePlugin fixed it?
  2. Was it necessary to add (or remove?) that default_proc snippet in some or all your plugins?

It still works if I remove both changes :grimacing:

What I also did is add a @name for each generated page. That seems to be the root cause…

1 Like

@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.

First, thanks a lot for working on Jekyll :+1:

My apologies for breaking the SemVer contract unknowingly.

Yep, that’s a good lesson to learn.

If you can provide the --trace output, perhaps that may shed some light on what exactly is the cause behind the break.

When I did, there was nothing wrong

In the end, since you managed to get things working again, what is the final outcome?

Yes, it now works. I think the root cause comes from the @name attribute

Did Jekyll 4.2.0 induce you to improve your plugin(s) or was it the opposite effect?

I improved the plugin, but breaking changes still suck :sweat_smile: