小智 27
我是该页面的作者http://www.garron.me/blog/multi-blog-site-jekyll.html
考虑到您需要个人档案页面,以及每个博客的最新帖子.只需使用这样的东西:
创建一个文件archives-blog-1.html并填写:
{% 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 %}
Run Code Online (Sandbox Code Playgroud)
这将为您提供blog1中所有帖子的列表,您可以对blog2执行相同的操作.该页面可以是您想要的任何地方.
对于最新的帖子,您可以使用相同的代码,但包含在:
{% for post in site.posts limit:5 %}
....
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
这将给你5个帖子......我正在使用它
{% 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 %}
Run Code Online (Sandbox Code Playgroud)
在我的索引页面中.http://www.garron.me/index.html ...在副标题下(来自博客)我不限于任何类别,所以所有博客的帖子都出现在那里,你可以限制{% if post.categories contains 'blog1' %}
希望它能帮到你.
到目前为止,有一个比任何答案都简单的解决方案.
文件夹结构:
- blog1/
- _posts/
- blog2/
- _posts/
然后在index.html for blog1中,使用site.categories.blog1而不是site.posts.
请参阅https://jekyllrb.com/docs/variables/中的 "site.categories"和"page.categories"文档.