Generate multiple files from one #16

vilcans opened this Issue Apr 25, 2009 · 12 comments

10 participants


I'd like to make pages that shows all the posts with a specific category/topic/tag. One such page should be created for each category/topic/tag.

E.g. if I have category "foo" and category "bar" I want Jekyll to generate the files /category/foo.html and /category/bar.html, each with a list of posts of that category. I don't want to create them manually if I have lots of categories.

So what I'm thinking about is some kind of "build description" file that specifies what files should be built and how.

Here's how that file can look in pseudo-code:

for each category:
    generate "categories/#{category}.html" from "_category.html"
for each topic:
    generate "topics/#{topic}.html" from "_topic.html"

Do you understand what I'm trying to say? Has anyone else thought about something like this and think it would be a good idea?

This could also be used to do something completely different from Jekyll's default behaviour if we want to. E.g. Jekyll's default would be to generate posts from the files in the "_posts" directory and "normal" pages from all other files, but it would be possible to override that with something else if needed.


I completely understand. I was just faced with this dilemma when porting my blog over from wordpress to jekyll. I ended up making a lot of little pages for separate categories for the time being. I would like some sort of DSL that is run to do this though.


I used Jekyll as a library from a Rakefile to be able to do just that. Works for the moment, but if definitely would be nice to have an easier way.

I doubt though that this could be achieved from within normal Liquid markup code. Maybe something for the config file?


I have already implemented generation of "category index" pages in my own fork (

It's not as flexible as it should be (I'm currently relying on the existence of a _layouts/category_index.html layout file and indexes are always generated at /category/xxxx/index.html), but it might work as a starting point and I'm willing to help in implementing this in core Jekyll if needed.


mattmatt: "I doubt though that this could be achieved from within normal Liquid markup code."

Wouldn't it be possible to do markup like:

{% for category in categories %}
  {% output categories/{{category}}/index.html %}
    {% for post in category.posts %}
      <a href="{{ post.url }}">{{ post.title }}</a>
    {% endfor %}
  {% endoutput %}
{% endfor %}

I mean we create a new Liquid tag called output that writes to a specific file.

I don't know anything about Liquid, so I have no idea if this is feasible.


Yes, that might work, though I'd find it confusing that a template file generates lots of other template files.


I've been thinking this over, and I believe vilcans solution is as nice as I can come up with. I suggest that like _layouts and _posts, these extra pieces could go somewhere like _templates.


@tomafro There's an _includes dir already.


The question is, do you think of a template as being the same as an include? I'm not sure...


If you would like to automatically create a page for each category that contains a list of posts that belong to it (like have a look at my extensions here:, namely category_gen


I've turned rfelix's category_gen into a proper ruby plugin,

Posts can be accessed like so:

{% for post in site.categories[page.category] %}
{{ post.content }}
{% endfor %}

The only issue I've come across is that they are not properly parsed (Markdown/Textile and Pygments). Using textilize solves the former problem, but not the latter, if anyone wants to take a stab.

Jekyll member

This can be closed IMO. And, after all, this is easily achieved by using plugins. Here's the one I wrote for my blog:

Jekyll member

Agreed. Thanks, @ixti.

@parkr parkr closed this Dec 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment