我正在尝试添加标签到我的博客基于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
标题:博客档案
{% include filter_by_tag.html %}
{% for post in site.posts %}{{ post.date | date_to_string }} » [ {{ post.title }} ]({{ post.url }})
{% endfor %}我不知道我在哪里出了问题,我试着跟踪这个博客文章这里的内容,尝试为我的博客复制同样的内容,但是我看不到生成和显示的标记。
不知道我哪里出了问题。
发布于 2019-04-28 13:41:45
我漏掉了文件
_data/tags.yml
它的内容就像
ansible:
name: ansible
apache:
name: apache诸若此类
https://stackoverflow.com/questions/55890709
复制相似问题