简体   繁体   中英

Jekyll: Page not parsing custom variable from layout

I've just begun learning Jekyll and I've run into a little speedbump.

I have 2 layouts in my _layout folder which essentially look like this:-

default.html

<html>
<head> <!-- Meta Tags etc --> </head>
<body>
    {{ content }}
</body>
</html>

hero.html

---
layout: default
---
<section id="hero">
    <h3>{{ hero.descr }}</h3>
</section>
{{ content }}

My index page extends the hero layout as follows:-

index.html

---
layout: hero
descr: Hello there.
---

The layouts work just fine, and the website appears as it should, except for the hero.descr variable. The heading tag is just empty.

The flow of data is uni-directional. default.html => hero.html => index.html

hero.html will not know what's defined in index.html

But, the rendering is in the opposite direction (inserted into the {{ content }} variable of the parent.

index.html ==> hero.html ==> default.html

It seems to me that the variable {{ hero.descr }} does not exist. I think that it should be {{ page.descr }} .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM