mediumish-theme-jekyll icon indicating copy to clipboard operation
mediumish-theme-jekyll copied to clipboard

Page per category/tag

Open jcuenod opened this issue 4 years ago • 4 comments

I have a lot of posts (more than I want to list on a single page). Would it be possible to generate a page for each category/tag?

jcuenod avatar Apr 09 '20 19:04 jcuenod

Yes. It's not that hard to implement :)

This theme already has jekyll-archive which is great! There's support for categories. You can navigate to /category/{category_name} to view archive of posts with that category.

To implement the tags, inside _config.yml file, replace the jekyll-archive part with this

jekyll-archives:
  enabled:
    - categories
    - tags
  layout: archive
  permalinks:
    category: '/category/:name/'
    tag: '/tag/:name/'

You will now be able to navigate to each tag with /tag/{tag_name}

MihajloNesic avatar Apr 19 '20 09:04 MihajloNesic

Thanks @MihajloNesic, I must say I can't figure out how to get the archive layout working (and I've looked at the docs for jekyll-archives but I'm clearly not understanding them, I'm not much of a jekyll user though, tbh). mediumish has a page for tags and for categories and both of them have permalink settings in the file header (I'm not quite sure how jekyll handles these). But I can't figure out how to use the variable to filter the posts (especially not in a way that results in a different page for each tag/category). Any pointers would be greatly appreciated!

jcuenod avatar Apr 20 '20 23:04 jcuenod

The archive layout is already defined in this template. Source.

You just need the archive layout and the configuration I provided in your _config.yml, along with the jekyll-archive gem. No need for separate pages or any front matter setting.

I can't find a good tutorial on this, but the jekyll-archive docs is fair enough. Try using this theme's archive layout (if you don't have a heavily modified site already).

MihajloNesic avatar Apr 21 '20 16:04 MihajloNesic

I haven't heavily modified this theme.

I see that the archive layout is defined but does the tags or categories layout in _pages not interfere with the archive layout?

Like I say, I read the jekyll-archives docs but its not clear to me that it's even possible to have a page for each individual tag/category.

I believe that I have figured out what I need in _config.yml and I understand what the archive layout is trying to do. Right now, it appears that archive.html doesn't actually get rendered (I get 404s when I navigate to /category/<anything>).

jcuenod avatar Apr 21 '20 18:04 jcuenod