Skip to content

a question when layout wrap layout #9065

Answered by ashmaroli
LawssssCat asked this question in Q&A
Discussion options

You must be logged in to vote

@LawssssCat I dug into the codebase. This is what I found:

Layout data gets merged hierarchically (parent onto child). The resulting data is exposed to the page as the top-level object {{ layout }}.

So in the case of :

---
layout: home
---

# Home Page

<pre>
  {{ layout }}
</pre>
---
layout: page
foo   : alpha
lorem : ipsum
cats  : [one, two]
---

<!-- from 'home' layout -->

{{ content }}
---
foo  : beta
gamma: delta
cats: [three, four]
---

<!-- from 'page' layout -->

{{ content }}

will render the following:

{"layout"=>"page", "foo"=>"beta", "lorem"=>"ipsum", "cats"=>["three", "four"], "gamma"=>"delta"}

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@LawssssCat
Comment options

@ashmaroli
Comment options

@LawssssCat
Comment options

Comment options

You must be logged in to vote
2 replies
@LawssssCat
Comment options

@MuhittinTekin
Comment options

Answer selected by LawssssCat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants