# Page Variable in Include

**URL:** <https://talk.jekyllrb.com/t/page-variable-in-include/2157>\
**Category:** Help\
**Created:** [September 14, 2018, 3:44am UTC](https://talk.jekyllrb.com/t/page-variable-in-include/2157 "2018-09-14T03:44:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frigidlight](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/frigidlight/32/503_2.png) [@frigidlight](https://talk.jekyllrb.com/u/frigidlight)\
**Post date:** [September 14, 2018, 3:44am UTC](https://talk.jekyllrb.com/t/page-variable-in-include/2157/1 "2018-09-14T03:44:04Z")

</div>

According to the documentation, I should be able to use a variable set in the front matter of a page in an include statement like so:

`{% include {{ page.my_variable }} %}`

However, when I attempt to serve my site with this method I get this error:

`Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences: Valid syntax: {% include file.ext param='value' param2='value' %} in /_layouts/page.html`

My variable set in front matter is `sidebar: sticker-sidebar.html` and my include statement is `{% include {{ page.sidebar }} %}`

I’ve tried a few things to solve the problem and it does work if the front matter variable includes a `-`. So `sidebar: sticker-` and `{% include {{ page.sidebar }}sidebar.html %}` works just fine. However, if I remove the `-` from the variable and add it to the include statement, the page breaks.

Is this a bug in Jekyll or some nuance of variables and includes that I can’t figure out?

---

<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 15, 2018, 6:25pm UTC](https://talk.jekyllrb.com/t/page-variable-in-include/2157/2 "2018-09-15T18:25:50Z")

</div>

interesting, not sure.

If your front matter is just `stickersidebar.html` will it work? sounds like you are saying no. but your first example has a dash.

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [September 16, 2018, 12:09am UTC](https://talk.jekyllrb.com/t/page-variable-in-include/2157/3 "2018-09-16T00:09:02Z")

</div>

What version of Jekyll?

I just did the following with Jekyll 3.8.3 and it’s works as expected.

1. Created `_includes/sticker-sidebar.html`
2. Added `sidebar: sticker-sidebar.html` to a page’s front matter
3. Added `{% include {{ page.sidebar }} %}` to the layout.

Site built with no errors and the test content in `sticker-sidebar.html` showed up. Do you have a public repo we can look at?

---

<div class="post-metadata">

**Author:** ![frigidlight](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/frigidlight/32/503_2.png) [@frigidlight](https://talk.jekyllrb.com/u/frigidlight)\
**Post date:** [September 16, 2018, 2:56pm UTC](https://talk.jekyllrb.com/t/page-variable-in-include/2157/4 "2018-09-16T14:56:58Z")

</div>

Sorry, my mistake there. If it ends in a trailing dash, it works. If the dash is included in the filename, it doesn’t work.
