Jekyll pagination on multiple pages

后端 未结 2 1979
刺人心
刺人心 2021-01-15 11:35

I am new to html/css but am attempting to create a blog using Jekyll and this theme I found here https://github.com/rosario/kasper

The homepage index.html has the al

相关标签:
2条回答
  • 2021-01-15 12:33

    You should share your code with your answer if you want a more detailed answer for your question. As far as I understood you are having trouble with creating a list of blog posts that are all same category. If this is correct then you can achieve it by using liquid for loop. If you look into the code on your index.html it has this for loop

    {% for post in paginator.posts %}
    

    If you modify it like below

    {% for post in site.categories.comedy %}
    

    Where comedy is a category name. This way we access the category within the site object and get all the posts under this category. If you place similar loops on your separate pages while changing the category names you can have different category lists on different pages. Make sure that you correctly input the category names in your post's front matter. If I succeeded in answering your question please mark the answer as correct.

    0 讨论(0)
  • 2021-01-15 12:39

    There is also another way to do that. Is using Jekyll Collections.

    For each collection you can have a _folder containing your markdown files. Then you can call your posts within this folder from whatever page you want.

    To do so, you will need to: 1st. add your collections to your _config.yml file:

    collections:
      example1:
        permalink: /example1/:path/
      example2:
        permalink: /example2/:path/
      example3:
        permalink: /example3/:path/
    

    2nd. create a folder to each collection, like: _example1, _example2 and _example3

    3rd. create a new html file from which you call each collection:

    {% for article in site.example1 %} ... {% endfor %}

    That's it! I hope to have helped. If I have, please mark this answer as useful. If you need more assistance, feel free to contact me.

    0 讨论(0)
提交回复
热议问题