jekyll / jekyll-help

NO LONGER MAINTAINED. USE JEKYLL TALK INSTEAD.
https://talk.jekyllrb.com
146 stars 19 forks source link

Loop trough subfolder of _posts? #293

Closed wesselgrift closed 9 years ago

wesselgrift commented 9 years ago

I can't seem to figur this out. Is it possible to loop trough posts and pages in a subfolder of "_posts"?

Like so:

{% for page in posts.staticpages %} {{ page.title }} {% endfor %}

budparr commented 9 years ago

I believe you're looking for site.categories.category_name I know that works for where you have:

category_name
  _posts
    2015-04-29-post-name.md

but not if the folder is within the _posts folder

wesselgrift commented 9 years ago

That's the thing, I want to be able to loop trough markdown files in a subfolder of the posts folder.

budparr commented 9 years ago

Well it's a clunky solution, but if you have or make something in your front matter that's consistent you can use the 'where' filter. Sorry I don't have a better solution!

jamesonzimmer commented 9 years ago

You could put the categories folders within the posts folder, like:

_posts category-a 2015-01-01-a-post.md category-b 2016-01-02-another-post.md

Maybe see https://github.com/mmistakes/so-simple-theme for example of using categories like this... Still clunky but at least keeps stuff within posts folder

Well it's a clunky solution, but if you have or make something in your front matter that's consistent you can use the 'where' filter. Sorry I don't have a better solution!

— Reply to this email directly or view it on GitHub https://github.com/jekyll/jekyll-help/issues/293#issuecomment-97780144.

wesselgrift commented 9 years ago

That's how I solved it now yes :) But its good to see that most people solve it like this, atleast I know there isn't a better solution.

Thanks

parkr commented 9 years ago

This repository is no longer maintained. Please search for your issue on Jekyll Talk, our new community forum. If it isn't there, feel free to post to the Help category and someone will assist you. Thanks!