Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page per category/tag #128

Open
jcuenod opened this issue Apr 9, 2020 · 4 comments
Open

Page per category/tag #128

jcuenod opened this issue Apr 9, 2020 · 4 comments

Comments

@jcuenod
Copy link

jcuenod commented Apr 9, 2020

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?

@MihajloNesic
Copy link

MihajloNesic commented Apr 19, 2020

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}

@jcuenod
Copy link
Author

jcuenod commented Apr 20, 2020

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!

@MihajloNesic
Copy link

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).

@jcuenod
Copy link
Author

jcuenod commented Apr 21, 2020

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>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants