Collections and categories - question about Autopages

Hi all, looking for some advice please.

I’ve done a lot of searching and want to ascertain the best way of achieving the below. My project is on the dev-jekyll branch here:

I have a project here which features blog posts and a single collection, Events. I plan to have categories enabled on both, and be able to link to a page that lists items within each category (and filtered by type).

For example, events/mobile/ and blog/mobile/ would list different content.

I’m new to jekyll (and enjoying it so far) but more experienced in WordPress. This would be very easy in WP, but seems challenging to do this in Jekyll automatically. (I am building the site for a client, so this needs to be very easy to manage, and manually creating category pages has more scope for error.)

Using jekyll-archive I have this working for blog but understand this doesn’t work for collections.

As I also need to add pagination, I was looking at the Autopages feature of jekyll-paginate-v2, but I’m finding the documentation confusing.

Does this plugin create archive pages per category or simply paginate them?

From what I read, the plugin should solve my problem but it looks like it’s unsupported on Jekyll 4 (which I’m currently running).

Any advice would be really appreciated.

Thanks!

category is a specific thing for posts but not for collections. You could have a front matter variable on a collection called category, but it would not get included with the posts, and would probably be bad form - since it is a reserved thing for posts.

I have not used that plug in so I can’t help on that. It is unclear at this point what your actual issue is, sort of sounds like you are set for posts but not for the collection? it may be difficult to set it up for collections, there is no concept of pagination for collection that I am aware of (could be wrong).

If there was only to be a few categories you could build your own page to list them, but again there would not be pagination.

Thanks - I’ve seen a few posts online about ways of tackling this but they all either:

  • create faux-category using front matter and then manually creating index pages for each (kinda what you’re suggesting)

  • using just posts but having two master categories and then sub categories

What I’m trying to achieve is fairly standard stuff, but perhaps not out of the box with jekyll. Essentially, you could substitute ‘Events’ in my example for ‘Portfolio’ - people often want to sort and filter their portfolio pieces and have a blog on the same site. There is a taxonomy for both content types.

you can also have them all be posts and make your own front matter called type (or whatever you want to call it) - and then have type: video or type:article or for you type: event and then use categories or tags and then divide stuff up that way.

I replied to your comment on the plugin’s repo, but essentially it boils down to this.

Categories and tags can be assigned to posts only, which are then available via the site.tags and site.categories objects… which is what I believe jekyll-paginate-v2 uses for Autopages… as well as jekyll-archives.

Pages and collection documents don’t have feature parity with posts… though that might have changed in Jekyll v4. If it has then what you want to do should be possible. I know there have been numerous talks about making posts, pages, and collections behavior similarly, but not sure if that has happened.

Autopages does what the name implies, generates pages automatically for you. It does this for all your tags via site.tags or categories via site.categories. It then has options to paginate each of those pages if you desire.

Update: I looked over the plugins docs and it does seem to imply it can do what you want. Though from this example I’m not entirely sure how it’s workin in that way.

Special autopages can be used that leverage the powerful filtering and sorting features of the pagination logic. For example you might want to create special pages autopages that paginate all tags in a certain collection or certain tags within a category.

Thanks again for your help, Michael. That’s great in that the plugin makes the other archives I need (standard stuff so I can drop Jekyll Archives plugin) and guess I’ll have to play about and see what Autopages can do.

Funnily enough I had the same reaction as you in the docs - that part suggests it’s possible but the example doesn’t match up.

I’ll use your fork and see what happens :slight_smile: