# Invalid syntax for include tag | Variable inside include {% %}

**URL:** <https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681>\
**Category:** Help\
**Created:** [June 20, 2017, 7:34am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681 "2017-06-20T07:34:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 20, 2017, 7:34am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/1 "2017-06-20T07:34:38Z")

</div>

- [x] I have a question about using Jekyll.
- [x] I updated to the latest Jekyll v3.5.0

* * *

- [x] I am on (or have tested on) _ **macOS** _ 10+

* * *

- [x] I was trying to build.

* * *

## My Errror Message

> Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences: image\_caption.html imageurl=“[http://blog.local/images/home/image.jpg](http://blog.local/images/home/image.jpg)” Valid syntax: {% include file.ext param=‘value’ param2=‘value’ %} in index.html

* * *

## My Reproduction Steps

- Use a variable inside an include tag, my example is:  
`{% include image_caption.html imageurl="{{ site.url }}/images/home/image.jpg" title="some title text" caption="some caption text" %}`

* * *

So I guess there’s some escaping to be done in this: `{% imageurl="{{ site.url }} %}` or is that not something achievable?  
I’m not into Ruby, so getting stuck here. Any advice appreciated.

---

<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:** [June 20, 2017, 5:55pm UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/2 "2017-06-20T17:55:51Z")

</div>

the problem is you cannot use curly brackets inside the include - it breaks it. So if you want to do that you have to assign the variable outside of the include:

> **[Includes](https://jekyllrb.com/docs/includes/#passing-parameter-variables-to-includes)**
>
> The include tag allows you to include the content from another file stored in the \_includes folder:

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 21, 2017, 5:56am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/3 "2017-06-21T05:56:09Z")

</div>

hey @rdyar, spot on! Your answer was great. I have been able to use the capture function.  
Thank you so much!

A question:  
I see that I cannot indent the caption on a newline, for example:

> ```
> {% capture img_url %}
> //some stuff here
> {% endcapture %}
> 
> ```

This produces some random weird characters. So it has to been all on same line:

> `{% capture img_url %}//some stuff here{% endcapture %}`

Why is that? (for my personal knowledge)

---

<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:** [June 21, 2017, 3:40pm UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/4 "2017-06-21T15:40:26Z")

</div>

That doesn’t sound correct to me, I have seen multi line capture statements before I think. Maybe it is your content.

That said I can’t think of anywhere I use capture so I don’t know for sure.

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 23, 2017, 2:07am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/5 "2017-06-23T02:07:27Z")

</div>

I have tried a couple of times, same behaviour, even with texts…  
I’m using Jekyllrb 3.5.0

---

<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:** [June 23, 2017, 4:22am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/6 "2017-06-23T04:22:21Z")

</div>

if you give a full example maybe someone will try it to see if they can verify it?

---

<div class="post-metadata">

**Author:** ![khayrattee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/khayrattee/32/292_2.png) [@khayrattee](https://talk.jekyllrb.com/u/khayrattee)\
**Post date:** [June 23, 2017, 5:16am UTC](https://talk.jekyllrb.com/t/invalid-syntax-for-include-tag-variable-inside-include/681/7 "2017-06-23T05:16:08Z")

</div>

It’s not a priority for me, I will get back to this post later for the sake of debugging the behaviour… cheers

And thank you again for all your amazing help @rdyar, you are awesome!
