Q: How should I pass assigned variables to an included Jekyll file? I use github pages to host a jekyll website. In order to quickly switch beetween the online base URL and the locale base URL, I have a variable in the start of my default layout file:
<!--{% assign root = site.github.url %}-->
{% assign root = "." %}

However, if I try to use that variable in an included file, it doesn't work. I know it should be refered as {{ include.root }} and I tried several variations so far, but none worked:
  {% include rail.html root =  root %}
  {% include rail.html root =  page.root %}
  {% include rail.html root =  {{ root }} %}

Any idea of what I should do?
Note that I am calling the include from an index file using the default.html file as layout. I can print the root variable correctly in that index file.
Also, how can I share a parent data context without having to pass all the parameters to my included file?

edit: it looks like I got something wrong. I tried to put inline posts into an include and the data context is perfectly shared. No idea why it doesn't work with my root variable only in the includes

A: Include tag has the following syntax: {% include file.ext param='value' param2='value' %}


*

*{% include rail.html root =  page.root %} does not work because root is not defined as an attribute of page.

*{% include rail.html root =  {{ root }} %} has wrong syntax, you must remove the whole line from the source code, or it will make the build fail.

*First one is correct: {% include rail.html root =  root %}
Then in _includes/rail.html : {{ include.root }} should print the root value, if that does not work the error is in another place, not in the include.
Side note
If you define the variable before the include, then you can use it directly without include.:
{% assign root = "." %}
{% include rail.html %}

In _includes/rail.html:
Hello {{root}}

