【发布时间】:2019-04-28 13:26:26
【问题描述】:
我正在尝试基于 jekyll hyde 向我的博客添加标签。
这就是我现在所拥有的。
_includes/filter_by_tag.html
<div class="message">
Filter by tag:
{% assign all_tags = site.data.tags %}
{% for tag in all_tags %}<a href="{{ site.url }}/blog/tag/{{ tag[0] }}">#{{ tag[1].name }}</a>
{% endfor %}
</div>
_includes/tags_for_page.html
{% assign post = page %}
{% if post.tags.size > 0 %}
{% capture tags_content %}{% if post.tags.size == 1 %}<i class="fa fa-tag"></i>{% else %}<i class="fa fa-tags"></i>{% endif %} {% endcapture %}
{% for post_tag in post.tags %}
{% assign tag = site.data.tags[post_tag] %}
{% if tag %}
{% capture tags_content_temp %}{{ tags_content }}<a href="/blog/tag/{{ post_tag }}/">#{{ tag.name }}</a> {% if forloop.last == false %}<!--comma-->{% endif %}{% endcapture %}
{% assign tags_content = tags_content_temp %}
{% endif %}
{% endfor %}
{% else %}
{% assign tags_content = '' %}
{% endif %}
_layouts/blog_by_tag.html
---
layout: default
---
{% assign tag = site.data.tags[page.tag] %}
<div class="page">
<h1 class="page-title">Articles by tag: #{{ tag.name }}</h1>
<div class="message">
All tags:
{% assign all_tags = site.data.tags %}
{% for tag in all_tags %}<a href="{{ site.url }}/blog/tag/{{ tag[0] }}">#{{ tag[1].name }}</a>
{% endfor %}
</div>
<div>
{% if site.tags[page.tag] %}
{% for post in site.tags[page.tag] %}
{{ post.date | date_to_string }} » <a href="{{ post.url }}">{{ post.title }}</a><br>
{% endfor %}
{% else %}
<p>There are no posts for this tag.</p>
{% endif %}
</div>
</div>
_layouts/post.html
comments: true
---
{% include tags_for_page.html %}
<div class="post">
<h1 class="post-title">{{ page.title }}</h1>
<span class="post-date">{{ page.date | date_to_string }} {{ tags_content }}</span>
{% if page.cover_image %}
<img src="{{ page.cover_image }}" alt="{{ page.title }}">
{% endif %}
{{ content }}
</div>
archive.md
title: 博客档案
{% include filter_by_tag.html %}
{% for post in site.posts %}{{ post.date | date_to_string }} » [ {{ post.title }} ]({{ post.url }})
{% endfor %}
我不确定我哪里出错了,我尝试关注这篇博文here 中的内容,尝试为我的博客复制相同内容,但我看不到正在生成和显示的标签。
不知道我哪里出错了。
- 链接到我的博客github repo 我正在尝试添加标签的地方
- link 到可以看到博客的博客。
- Commit hash 我尝试添加标签的地方
【问题讨论】:
标签: jekyll github-pages hyde