Lars
Lars

Reputation: 8458

Paginating with Jekyll

On my site, I have a portfolio of projects. I want a subcategory overview page, which lists all projects which have the subcategory, and to be able to paginate through this list.

I have a working template to get all the projects for a given subcategory, but how can I now paginate this?

  {% for project in site.pages %}
    {% if project.layout == 'project' and project.subcategories contains page.title %}  
      <h3><a href="{{ project.url }}">{{ project.title }}</a></h3>
    {% endif %}
  {% endfor %}

IE I want to display the first 10 projects, then have a link to the next 10 and so on.

Please note my project pages are not posts, and are separate from my _posts directory.

Upvotes: 1

Views: 387

Answers (1)

Polygnome
Polygnome

Reputation: 7820

This is not possible without a plugin.

You should write your own generator for that. Take a look at http://jekyllrb.com/docs/plugins/ how to do that.

Im not that good at ruby, but you will probably want your generator to loop through site.pages, check the layout and then add proper pages to the site.pages array.

This won't work on GitHub-Pages, though!

Upvotes: 3

Related Questions