Tagging in custom collections

I have a Jekyll website that differentiates press releases and blog posts. Rather than putting posts inside the standard _posts folder, I created _press and _blogs. The website has some 80 posts, and it’s difficult to modify the content of each due to this large quantity.

After putting posts into _press and _blogs, jekyll-tagging and jekyll-paginate-tags plugins stopped working. Whilst tags can continue to be accessed with item.tags where item is in site.press and site.blogs, the plugins failed to generate tag list pages based on template.

How do I make jekyll tags work in custom collections like _press and _blogs, and how do I use :year, :month, and :day variables in urls for posts in these custom collection folders?

if you are using collections and not posts you will likely loose some of the category and tag specific things that jekyll does as those only happen to posts. Outside of the posts folder they will still be accessible as custom front matter but they will no longer do the things that post tags and cats can do.

it is a little weird to wrap your head around but tags and posts are special sort of reserved variables that you should probably only use within the posts folder to avoid confusion.

Since you are using a couple plugins that I am unfamiliar with there could be more to it, but from a strict jekyll standpoint I think your issue is you are expecting a post behavior for tags that is not happening cause you are not using posts but a collection instead.

Posts are a collection but with special characteristics not available to other collections.

Thanks for your response. I think the plugins are Ruby gems, so there should be a way to customise these plugins. Unfortunately, I’m not familar with the Ruby ecosystem.

My goal is to divide the posts into two groups. This came up to my mind after posting 80 posts. I think it’s too much work to use tags or categories to group the posts because there are so many of them. The dirtest and easiest way to do this is to throw these posts, which are originally inside the _posts folder as you said, into custom collection folders. This way I can separate them without opening each file and add some tags or categories to achieve this grouping effect.

Since post behaviours are absent in collections, do you have a better way to group the posts without having to add tags and categories some 80 times whilst retaining this post behaviour?

You can use sub folders as categories for posts - I don’t remember if the sub folder goes in the _posts folder or vice versa - might even work both ways.

more info - see file path category stuff

2 Likes

Thank you, @rdyar, for helping out. After doing research, categories indeed is the answer I’ve been looking for. And, we don’t need to open up each post to add frontmatter data to define categories. The same results using _press and _blogs can be achieved with press/_posts and blogs/_posts. I didn’t know it’s possible to have multiple _posts folders. Even better than using collections, now tags continue to work. I’m very happy with this solution. If anyone’s in a similar situation like this with some 100+ posts or more to group by types or topics, use categories. Simply create more _posts folders and move them inside categories folder. There’s no need to define categories in frontmatter.