Create a website with Jekyll that has a subdirectory for paginated blog content

I am building a site with Jekyll where the main page (jekyllsiteblogpaginated.com/index.html) does not display the contents of the blog. In addition, I would like to create a subdirectory for the blog where the main page, jekyllsiteblogpaginated.com/blog/index.html, displays the page breakdown.

I clicked here my example http://bpatra.imtqy.com/jekyllsiteblogpaginated . Github repository can be found here

You can see in the branches of the repository that I tested several organizations: creating a blog subdirectory with the index.html file or adding the blog.html file directly at the root level. I also tried using the paginate_path option, but also without success, paginator is always empty.

This question is similar to this one , the user says in a comment that he finally used the plugin. I would like to avoid the plugin because my site will be hosted on github pages.

+4
source share
1 answer

I did it!

1 - Add to config.yml

paginate_path: "/blog/page:num"

2 - In your code:

{% for post in paginator.posts %}

but not

{% for post in paginated.posts %}

3 - The last thin point. As seen at the bottom of the Jekyll variables doc

Paginator

, , /blog/index.html.

, blog.html blog/index.html, , , .

Et voilà!

+17

Source: https://habr.com/ru/post/1548203/


All Articles