如何在集合中搜索具有特定前题的帖子(液体)

时间:2019-02-13 14:23:17

标签: collections jekyll

我在分配后事时遇到一些问题。因此,这是合集中以_programming命名的帖子的前题:
/_programming/somepost.md

---
title: "Layout: Header Image (Horizontal)"
header:
  image: /assets/images/unsplash-image-1.jpg
  caption: "Photo credit: [**Unsplash**](https://unsplash.com)"
categories:
  - Layout
  - Uncategorized
tags:
  - edge case
  - featured image
  - image
  - layout
---

This post should display a **header image**, if the theme supports it.

Non-square images can provide some unique styling issues.

This post tests a horizontal header image.
  

这篇文章来自最小的错误

但是,我有很多帖子中有categories: Layout。帖子只能包含一个类别或几个类别,如上。

我想在收藏中发帖。为此,我尝试了以下代码:

---
permalink: /study/layout/
title: Layout
subject: Layout
layout: study_theme
---

{% assign subject=page.subject %}
{% for temp in study.programming %}
  {% if temp.categories == subject %}
    <a href="{{ temp.url | prepend: site.baseurl }}"> 
     <p>{{ temp.title }}</p>
    </a>
  {% endif %}
{% endfor %}

这段代码:

---
permalink: /study/layout/
title: Layout
subject: Layout
layout: study_theme
---

{% assign subject=page.subject %}
{% for temp in study.programming %}
  {% if temp.categories contains subject %}  //only here changed
    <a href="{{ temp.url | prepend: site.baseurl }}"> 
     <p>{{ temp.title }}</p>
    </a>
  {% endif %}
{% endfor %}

但是这些代码不起作用。请帮我。我在页面中看不到任何帖子。

0 个答案:

没有答案