Multiple Blogs on One Site1

Suppose that you have two categories of blogs. There are two ways to create directories in your website folder

  1. --blog1
        |--_posts
    --blog2
        |--_post
    
  2. |--_posts
        |--blog1
        |--blog2
    

The first approach will automatically assign categories to your posts.

Using the second approach, you will need to manually add category: your_blog_folder_name to Yaml Front Matter in each post.

---
layout: default
title: Blog1
category: blog1
---

You also need to modify the default layout template for the category blog1 by adding a filter using post.categories contains 'category name' to where it is appropriate. For example,

{% raw %}
{% for post in site.posts %}
  {% if post.categories contains 'blog1' %}

[{{ post.title }}]({{ post.url }})

  {% endif %}
{% endfor %}
{% endraw %}

See Jekyll help document on Posts for more information on how to modify a template



Updated on 3/14/2020.


  1. I learned this trick mainly from the post Create a Multi Blog Site with Jekyll written by Guillermo Garron. ↩︎


Edited on 2024/03/18