Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Blogs In Single Jekyll Website

Tags:

ruby

jekyll

Is there a way I can have a single Jekyll website have more than one blog? I currently want to have two blogs in one site.

like image 781
chirag7jain Avatar asked Jan 28 '13 11:01

chirag7jain


People also ask

Can you have multiple blogs on one website?

You Can't Have Multiple Blogs. At least, not by default. The way that the WordPress Core is set up, each installation is an individual site. It has one database with one set of users tied to it.


1 Answers

I am the author of the page http://www.garron.me/blog/multi-blog-site-jekyll.html

Considering that you need individual archives pages, and latest post per individual blog. Just use something like this:

Create a file archives-blog-1.html and fill it with:

{% for post in site.posts %}
  {% if post.categories contains 'blog1' %}
    <div class="post">
        <h3 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h3>
        <p class="meta">Date: {{ post.date }}</p>
    </div>
  {% endif %}
{% endfor %}

That will give you a list of all post in blog1, you can do the same for blog2. That page can be anyplace you want.

For the latest post, you can use the same code but enclosed between:

{% for post in site.posts limit:5 %}
....
{% endfor %}

That will give you the lastes 5 posts... I am using this

{% for post in site.posts limit:5 %}

  <div class="post">
    <ul>
      <li><a href="{{ post.url }}">{{ post.title | truncate:200 }} </a><small>{{ post.date }}</small>
         {% if post.summary %}
            <p class="entry">{{ post.summary }}</p>
         {% endif %}
      </li>
    </ul>
  </div>
{% endfor %}

In my index page. http://www.garron.me/index.html ... under the sub-title (From the blogs) I am not limiting to any category, so posts from all blogs appear there, you can limit with {% if post.categories contains 'blog1' %}

Hope it helps you.

like image 130
ggarron Avatar answered Oct 10 '22 16:10

ggarron