Please, help me to understand. I have 3 questions about category pages on Jekyll.
If I want to create a category page, I should just create a page, where write loop {% for %} to get post lists? And then how to get URL of specific category?
And If I have 5 categories with different design layouts, then I should create 5 different pages for categories?
Should I put category files in a special folder, like _category or something else? For example, all website posts I should put into the _posts folder.
Sorry for bad English, friends. Love you all and thank you for help!
jekyll on its own does not have an easy way to make the category pages, so yes, you can create a page for each category, or one page for all categories and loop thru them to get what you want. There is no right or wrong way to do it.
Posts have to be in a _posts folder, you can put a _posts subfolder into a parent folder called cats and jekyll will consider the parent folder of cats to be a category for any posts in that folder.
You can have more than one _posts folder, so you could have folders named cats, dogs and birds and each of those could have a sub folder called _posts, and post in that sub folder would have the parent folder as a category.
That said I don’t see any actual documentation for that and I find it a little confusing, I would think there would be one _posts folder with sub folders in it and those would be the categories but I don’ think it works that way.
You can of course just set the category in the posts front matter.
Thank you very much, rdyar! You always help me out!
I no have problems with creating pages for categories, then I can create loop to get post lists.
But one of my questions remained unanswered. If I set category on Front Matter with writing cats into the post.
Then I create page cats.md for category. How I should setting permalinks for this category? If on post’s Front Matter written cats, permalink on cats.md page should be /cats?
And is all this done manually? In post’s Front Matter I write the category, and on the category page (cats.md) I write permalink. So easy to make a mistake)
you don’t need to do the permalink on any of the pages, it is optional. You normally set the permalink in the config file where it would affect all pages/posts. This is configurable, but generally the post permalink would include the category and the post title - and sometimes the date if you like that. The cats category page would be a page and not a post, and generally that is title only.
Man, you bit don’t understand me, sorry. Our English is so bad))
My question about permalink settings for categories:
If I write category cat on the post’s Front Matter.
Then for cat page (categories page) I write permalink: cat-category . How will it work? Permalink of the cat 's category will be cat , or cat-category ?
Using the word Cat in an example for a category was a terrible idea, I apologize. Now when you say cat I don’t actually know what you are referring to - cat - meow, or cat as a category.
Lets say you have an article about dogs, so it has a category of dogs. You then have a page called dogs.md where you list all of the articles about the dogs category.
The permalink of the page where you list all of the items from the category will not change anything else - so if you have a permalink of /dog/ or /dog-category/ that will only be on that page, it will not effect an article about dogs that has that as a category.
Best bet is to try things out - then ask a question of why something does not work (if that is the case). Asking hypothetical questions makes it hard to give an answer.
Thank you very much, rdyar! Now you understand me, and I understand you too.
Yes, I meant it! I write article about Rabbit breeding. And I set category rabbit for this article.
Then I create page rabbit.md, where I display all my articles about rabbits. And I can change category url for rabbit.md page (example: hot-rabbits), and this will not affect the work in any way.