Jekyll only shows the tag on the page

I use jekyll and I try to show on the page (/ play) only those messages marked as Play, and the same with Work (/ work). How can i do this?

Thanks.

+4
source share
2 answers

You can do this by iterating through site tags and indexing into an array with a tag name similar to the following:

{% for post in site.tags.Play %}
<h2>{{ post.title }}</h2>
<time>{{ post.date }}</time>
{% endfor %}

This is a bit confusing because it seems to site.tagsreturn a collection of tags, but actually contains complete messages indexed by the tag.

See site.tags.TAGthe Jekyll Variables page .

+2
source

@briantist is right, you need to dig into the site.tags collection.

, Jekyll .

(: ruby.html) include, ruby:

---
layout: page
title: Ruby
---

{% include tagPagesLoop.html tagName='ruby' %}

_includes/tagPagesLoop.html

<h2>All {{ include.tagName }} posts</h2>

{% for post in site.tags[include.tagName] %}
<h3>{{ post.title }}</h3>
other stuff here
{% endfor %}

, , , .

+1

Source: https://habr.com/ru/post/1615382/


All Articles