# How to access layout data in page/post?

**URL:** <https://talk.jekyllrb.com/t/how-to-access-layout-data-in-page-post/7640>\
**Category:** Help\
**Created:** [September 9, 2022, 3:40pm UTC](https://talk.jekyllrb.com/t/how-to-access-layout-data-in-page-post/7640 "2022-09-09T15:40:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlconlin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jlconlin/32/2845_2.png) [@jlconlin](https://talk.jekyllrb.com/u/jlconlin)\
**Post date:** [September 9, 2022, 3:40pm UTC](https://talk.jekyllrb.com/t/how-to-access-layout-data-in-page-post/7640/1 "2022-09-09T15:40:03Z")

</div>

I have a custom layout where I assign data like this:

`mylayout.html`

```auto
{% assign data = "my data" %}

```

I’d like to use this data in the page that uses the layout:  
`mypage.md`

```auto
---
layout: my layout
---
data: {{ data }}

```

When I do this, I get empty content. I’m assuming the page doesn’t know about the `data` variable from the layout.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [September 9, 2022, 5:25pm UTC](https://talk.jekyllrb.com/t/how-to-access-layout-data-in-page-post/7640/2 "2022-09-09T17:25:14Z")

</div>

not sure I have seen that type of thing with a layout - but I think you can do it with an include. Have you tried that?

---

<div class="post-metadata">

**Author:** ![jlconlin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jlconlin/32/2845_2.png) [@jlconlin](https://talk.jekyllrb.com/u/jlconlin)\
**Post date:** [September 9, 2022, 6:57pm UTC](https://talk.jekyllrb.com/t/how-to-access-layout-data-in-page-post/7640/3 "2022-09-09T18:57:30Z")

</div>

Interesting thought. That does work with an include. Thanks!
