如何为 GitHub 上托管的 jekyll 博客添加适当的标签支持?

How can I add proper tag support for jekyll blog hosted on GitHub?

问题

最近我为我的个人博客添加了标签支持,但我对它的完成方式不满意。

博客使用 with ,所以我的解决方案有很多平台自带的限制。

为了创建标签 javascript 我创建了包含以下内容的文件 tag/javascript/index.html

---
layout: tag
tag: javascript
---

在我的 tag 布局文件中,我有以下代码:

---
layout: default
---
<div class="tag-header">
    posts related to <strong>{{ page.tag }}</strong>
</div>
{% for post in site.posts %}
{% if post.tags contains page.tag %}
<section class="post">
    <header>
        <a href="{{ post.url }}">{{ post.title }}</a>
    </header>
    <time>
        {{ post.date | date_to_string }}
    </time>
    <summary>
        {% if post.excerpt %}
        {{ post.excerpt }}
        <a href="{{ post.url }}">read more</a>
        {% endif %}
    </summary>
    <div class="tags">
        {% for tag in post.tags %}
        <span>
            <a href="/tag/{{ tag }}">#{{ tag }}</a>
        </span>
        {% endfor %}
    </div>
</section>
{% endif %}
{% endfor %}

结果是这样的posts related to javascript

问题

我如何自动化标签创建过程,这样它就不需要手动创建 标签 文件(示例中的 tag/javascript/index.html)?

通知

我读过 An easy way to support tags in a jekyll blog already, and the only working solution for was this one,我不喜欢它,因为它把所有标签都放在一页上。

另外请注意,我使用的是 ,因此自定义插件不是一个选项。

您可以找到 full sources here.

当前Jekyll (3.1.x)无法自动生成标签页。您需要使用自定义插件。但你不想。

为什么?在 github 页上更改部署过程并不难。

您可以将代码存储在 master 中,并在 gh-pages 中生成页面。 将为您提供有关如何操作的更多信息。