I have a custom page for Jekyll: I have a news.markdown file like the following:
{% assign posts_per_page = 5 %}
{% for post in site.categories.ro offset:pagination_skip limit:posts_per_page %}
...
{{ post.content }}
...
{% endfor %}
{% include nav.html %}
Where nav.html is in the _includes directory and it looks like this:
{% if pagination_skip %}
{% capture pagination_skip %}
{{pagination_skip | plus: posts_per_page}}
{% endcapture %}
{% else %}
{% assign pagination_skip = posts_per_page %}
{% endif %}
<div class="next">
<a rel="prev" href="{{site.basepath}}ro/news/{{ pagination_skip }}">Next</a>
</div>
What I want is for the url .../ro/news/5 to be mapped to the content of news.markdown such that pagination_skip there is 5. Same for 10, 15, whatever. Moreover, .../ro/news/0 should be the same as .../ro/news/ if possible.
Can I do that? How?
I’d like to use as few extensions as possible.
You try to do it wrong. You want to have a dynamic handling of a URL parameter. Jekyll is a static web generator. So you need to generate all the page that will be visited. You can a generator for that. Please have a look at Generator section on page https://github.com/mojombo/jekyll/wiki/Plugins
I worked on a generator for what you want to do and it works pretty nicely, I also created the ‘prev’ and ‘next’ button. Please have a look and try it. It works for all categories (not only the ro one), but you can customize it if you want.
folder structure
the genrator
news.rbruby codeThe layout of the
news.htmlfileThe include navigation
nav.htmlGive it a try and let me let me know if you like it.