2021年5月2日星期日

Is it possible to pass data from generated collection pages in Jekyll to the layout?

I have a collection of items that outputs a unique page per item, and I want those items to each have unique preview images when you embed them in Twitter, Discord, etc. To that end, I have the following code in my default.html layout

<head>     ...     <meta property="og:image" content="" />  </head>  

Then, in the layout file for the individual item, I have front matter like

---  layout: default  preview:   ---    

And finally in item.md itself, I have front matter like

---  icon: /assets/img/preview_img.png  ---  Item content goes here  

The issue here is, the variables seem to get lost somewhere along the way. Specifically, in going from item.html -> default.html. I'm guessing this is a limitation with either collection pages or fluid in general, does anyone know a way around this?

https://stackoverflow.com/questions/67363349/is-it-possible-to-pass-data-from-generated-collection-pages-in-jekyll-to-the-lay May 03, 2021 at 12:05PM

没有评论:

发表评论