【问题标题】:Jekyll: Access attribute of collection?Jekyll:集合的访问属性?
【发布时间】:2018-09-03 21:24:03
【问题描述】:

我正在尝试创建第二个行为相似的_posts(它可以链接到,它有自己的布局,它存储在_works 文件夹中,每件作品都以some-name.md 命名)。

一切都很好,除了我找不到如何访问该降价文件的 frontmatter 属性...唯一有效的变量是 {{content}} 但我想访问所有其他属性。

_config.yml

collections:
  works:
    output: true

layouts/work.html

---
layout: default
---

<div class="work-single">
  <h1>{{ work.title }}</h1> ... doesnt work
  <h2>{{ work.subtitle }}</h2> ... doesnt work

  {{ content }}
</div>

_works/test-product.md

---
layout: work
date: 2018-03-25 01:00:00 +0900
category: illustration
title: A test work product image
subtitle: This is a great product
---

Here is a test of a product which uses **markdown**.

【问题讨论】:

    标签: github jekyll github-pages yaml-front-matter


    【解决方案1】:

    在模板内部,page 对象可用:{{ page.title }},依此类推。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-20
      • 2020-04-14
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 1970-01-01
      • 2019-11-07
      • 2017-05-28
      相关资源
      最近更新 更多