单个Jekyll网站中的多个博客
有没有办法让一个Jekyll网站有多个博客? 我目前想在一个网站上有两个博客。
我是该页面的作者http://www.garron.me/blog/multi-blog-site-jekyll.html
考虑到您需要个人档案页面,以及每个博客的最新post。 只需使用这样的东西:
创建一个文件archives-blog-1.html并填写:
{% for post in site.posts %} {% if post.categories contains 'blog1' %} {% endif %} {% endfor %}
这将为您提供blog1中所有post的列表,您可以对blog2执行相同的操作。 该页面可以是您想要的任何地方。
对于最新的post,您可以使用相同的代码,但包含在:
{% for post in site.posts limit:5 %} .... {% endfor %}
这将给你5个post……我正在使用它
{% for post in site.posts limit:5 %} - {{ post.title | truncate:200 }} {{ post.date }} {% if post.summary %}
{{ post.summary }}
{% endif %}
{% endfor %}
在我的索引页面中。 http://www.garron.me/index.html …在小标题下(来自博客)我不限于任何类别,所以所有博客的post都出现在那里,你可以限制{% if post.categories contains 'blog1' %}
希望它能帮到你。
到目前为止,有一个比任何答案更简单的解决方案。
文件夹结构:
- blog1/ - _posts/ - blog2/ - _posts/
然后在blog1.for blog1中,使用site.categories.blog1
而不是site.posts
。
请参阅https://jekyllrb.com/docs/variables/中的 “site.categories”和“page.categories”文档。
我使用两个单独的Jekyll安装在同一个域上运行两个博客 ; 如果你的博客将生活在单独的根目录中(我的博客位于/
和/photos/
),那么我建议采用这种方法。 我还描述了如何合并两个博客的sitemap.xml文件 。
您最好的选择是查看数据文件function。 您可以将.markdown
文件放在.markdown
中的单独文件夹中,并在发布时链接到它们。 这确实意味着,为了发布post,您需要编写一个数据文件条目,但您可以根据需要托管尽可能多的“博客”,每个博客都有自己的文件夹。 post会自动将其所在的文件夹作为url。 我将此方法用于我自己的个人博客和投资组合。
或者,或者您可能想要查看集合: http : //jekyllrb.com/docs/collections/