Category in github. The semi-automatic way
Plugin free, with only a little work to do.
- 1. Add categories in the post
- 2. Add link of categories in index.html
- 3. Create layout file for category index page
- 4. Create index page for each category
- Reference
As we know, github doesn’t allow us to use plugin in jekyll for security reason. So, here comes the problem. How can we use category?
After some test, I finally find a semi-automatic way to do that. Here’s how.
1. Add categories in the post
Add keyword categories in the post, like the fellowing:
--- layout: post title: Category in github. The semi-automatic way categories: jekyll --- Content of the post.
2. Add link of categories in index.html
Create a category.html in the _include directory
After that, include category.html in index.html
3. Create layout file for category index page
Create file category_index.html in _layout directory.
4. Create index page for each category
For every category, create a sub directory the same name of category in directory ‘categories’, add create a index page with name index.html in that sub-directory.
For example, we have a category with name ‘jekyll’, what we should do is:
The content of categories/jekyll/index.html is:
For short, we can execute the fellowing bash, create_category.sh, to create sub-directory & index file.
For example:
Still don’t know how to do? Just clone my blog from github.
Reference
This article is released under CC BY-NC-SA 3.0 license.