Tallboy
Tallboy

Reputation: 13407

Jekyll: Access attribute of collection?

I'm trying to create a second _posts that behaves similar (it can be linked to, it has it's own layout, it's stored within the _works folder, and each work is titled with some-name.md).

Everything works great, except I can't find how I access the frontmatter attributes of that markdown file... The only variable that works is {{content}} but I want to access all the other attributes.

_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**.

Upvotes: 1

Views: 363

Answers (1)

David Jacquel
David Jacquel

Reputation: 52789

From inside template, the page object is available : {{ page.title }}, and so on.

Upvotes: 1

Related Questions