jekyll-datapage_gen icon indicating copy to clipboard operation
jekyll-datapage_gen copied to clipboard

Documentation: How to use Jekyll category/tag in generated pages?

Open inetbiz opened this issue 3 years ago • 2 comments

I am creating a product site. I need to use category/tag pages built into Jekyll. Ideas?

inetbiz avatar Mar 09 '21 12:03 inetbiz

Just dealt with this, try this! (Mind you Page variables like content or title are reserved by Jekyll Layouts object, maybe there should be a _templates dir?)

product.yaml

- id: Soap
  template: template
  data: The best Soap for Ever Lasting Life!
  category: home 
  tags: on-sale, organic

template.md

---
title: {{ page.id }}
layout: {{ page.template }}
category: {{ page.category }} 
tags: {{ page.tags }}
---

# {{ page.id }}

> {{ page.data }}

hope this works!

desirtech avatar May 13 '21 20:05 desirtech

First of all thanks for the report, thanks to @jeffreydesir for the feedback, and sorry for taking ages before answering your question.

Just to add my two bits, you can also use =page_data_prefix= to prefix the variables and avoid clashes with reserved words.

config.yml

- data: product
   page_data_prefix: my

product.yaml

- id: Soap
  template: template
  data: The best Soap for Ever Lasting Life!
  category: home 
  tags: on-sale, organic

template.md

---
title: {{ page.my.id }}
layout: {{ page.my.template }}
category: {{ page.my.category }} 
tags: {{ page.my.tags }}
---

# {{ page.my.id }}

> {{ page.my.data }}

avillafiorita avatar Feb 08 '22 15:02 avillafiorita