'Proper rendering of posts by tag and by author in Octopress' post illustration

Proper rendering of posts by tag and by author in Octopress

avatar

Octopress has generation of per tag index. By default it shows only post title. This works okay, until the moment when you will want to customize category_index.html and try to output some excerpt of post content too. You will face the issue that post content renders incorrectly. This is a problem in plugins/category_generator.rb plugin.

The same problem exists in author_generator.rb plugin.

In both of these plugins one can find the code:

1
2
3
4
5
index = CategoryIndex.new(self, self.source, category_dir, category)
index.render(self.layouts, site_payload)
index.write(self.dest)
# Record the fact that this page has been added, otherwise Site::cleanup will remove it.
self.pages << index

This code is wrong. The Jekyll engine suppose have different phases for page generation, e.g.: reset, read, generate, render, cleanup and write. Each of this phase is run across all the pages. But plugins for Jekyll are supposed to only override generate phase. The rest of the phases should be done by the Jekyll engine itself.

In the code above we see that plugin tries to make generate, render and write, during generation phase, this is wrong. The plugin is supposed to do only generate phase, the rest are done by Jekyll engine.

The bug fix is very simple, just remove or comment out all occurencies of the lines below in categorygenerator.rb and authorgenerator.rb plugins.

1
2
index.render(self.layouts, site_payload)
index.write(self.dest)

This will fix all the rendering issues.

If you're looking for a developer or considering starting a new project,
we are always ready to help!