Jekyll blog show posts under a category

前端 未结 3 1555
孤城傲影
孤城傲影 2021-01-03 04:08

I want to show posts that are from a certain category. For example, going to url http://example.com/posts/programming will list all the posts that have \"programming\" as th

3条回答
  •  灰色年华
    2021-01-03 04:43

    I can of course create a directory dedicated to each category and then make index.html inside it, but there must be a better way.

    This is a great way to do it, isn't much work at all and works flawlessly on gh-pages. It's exactly what I do on my own sites as I prefer to keep my .md posts filed by category in the directory structure, so I simply have:

    /blog/
        /_posts/20015-01-01-my-awesome-post.md
        index.html
    
    /labs/
        /_posts/20015-01-01-my-technical-post.md
        index.html
    

    I find it preferable for maintenance to not have 1001 posts all in _posts/ and I get the pretty permalink structure I want without entering categories in each posts front-matter.

提交回复
热议问题