How to fix "Deprecation: Document#categories is now a key in the #data hash."

I’m building my jekyll site and getting this warning:

8:58:41 AM:        Deprecation: Document#categories is now a key in the #data hash.
8:58:41 AM:        Deprecation: Called by ["/opt/build/cache/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/document.rb:400:in `method_missing'"].

How do I fix it?

Hello @flyingfisch!
Are you using any plugins? If yes, please list them.
Are you using a theme-gem? (check for key theme: in your config file) If yes, please post its name.

I am not using a theme gem that I am aware of. I am using the following plugins:

asset_path_tag
category_archive_plugin
generate_categories
kramdown_pygments
jekyll-paginate

Most of those are custom plugins, it may help just to link the source code: https://github.com/flyingfisch/flyingfisch.github.io-src

The following definition was found in the category_archive plugin:

def posts_group_by_category(site)
  category_map = {}
  site.posts.docs.each {|p| p.categories.each {|c| (category_map[c] ||= []) << p } }
  category_map
end

Within the outer braces on line#3 above is the usage p.categories.each
This usage is deprecated and not recommended since Jekyll 3.0 and above. The recommended approach is to use p.data['categories'].each instead.

Thank you! That solved the problem. :slight_smile: