多个Jekyll网站中的多个博客 [英] Multiple Blogs In Single Jekyll Website

查看:51
本文介绍了多个Jekyll网站中的多个博客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让我一个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.

推荐答案

我是该页面的作者考虑到您需要单个存档页面,以及每个单个博客的最新帖子.只需使用以下内容即可:

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

创建一个文件archives-blog-1.html并填写:

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 %}

这将为您提供blog1中所有帖子的列表,您可以对blog2执行相同的操作.该页面可以在您想要的任何地方.

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 %}

这将为您提供持续5篇帖子...我正在使用

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 %}

在我的索引页面中.在副标题下 http://www.garron.me/index.html ...(来自博客) 我不受任何类别的限制,因此所有博客中的帖子都显示在此处,您可以使用{% if post.categories contains 'blog1' %}

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' %}

希望它对您有帮助.

这篇关于多个Jekyll网站中的多个博客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆