jekyll/jekyll-redirect-from

Calling 'site.docs_to_write' prevents other generators from working properly

radoslavkarlik opened this issue · 5 comments

Calling site.docs_to_write in generator.rb will make the site object remember the result of the first call which means that content generated later from other generators will not be taken into consideration. Took me a lot of time to figure out why is my content not being generated anymore.

@radoslavk What version of Jekyll are you using..?

@ashmaroli 3.8.5, I have fixed the issue with a higher plugin priority so my content is being generated before the docs_to_write is called

This is probably because of the caching incorporated into the method:

    # Get the to be written documents
    #
    # Returns an Array of Documents which should be written
    def docs_to_write
      @docs_to_write ||= documents.select(&:write?)
    end

I am not sure why Jekyll allows calling that method from the outside. Maybe you could rethink the usage of documents.select(&:write?) directly, so any other generator's new documents are not omitted unless jekyll-redirect-from is called last. Jekyll internally calls docs_to_write when writing the final output.

This should be fixed in Jekyll core.