Happily, the fix is simple. The problem is that your code assumes every page will have an array of categories. That isn't the case for atom.xml so context.environments.first["page"]["categories"]
will return nil
which, of course, doesn't have the method 'size'. You can set it to only output if get_categories returns a value and you're all set.
module Jekyll
class ConnexeTag < Liquid::Tag
def render(context)
categories = get_categories(context)
# return a list of categories for pages which have them
categories.join(', ') if categories
end
private
def get_categories(context)
context.environments.first["page"]["categories"]
end
end
end
Liquid::Template.register_tag('connexe_tag', Jekyll::ConnexeTag)
That should do it.