{% include sidebar.html links=page.relatedpages %}
<!--
Now in sidebar.html you have access to the links variable through include.links. You can now use the contents of this variable like any other liquid variable, e.g.
-->
{% if include.links %}
...some code..
{% endif %}
<!--
You can pass in as many different variables as you like.
-->
{% include sidebar.html links=page.relatedpages title=page.title %}
<!--
You can pass in absolute values as well by surrounding the value with quotes.
-->
{% include sidebar.html links=page.relatedpages title='My awesome page' %}
<!--
If you pass in multiple values with the same name then they overwrite each other (i.e. only the last value will be available). In the example below only the value "title2" will be available for variable include.title in the sidebar.html include.
-->
{% include sidebar.html links=page.relatedpages title='title1' title='title2' %}
<!--
If you want to combine argument values or concatinate them you will need to first capture the value in a new variable and then pass that into the include. In the example below I create a new variable new_title and then pass it into the include.
-->
{% capture new_title %}Welcome to my page titled {{page.title}} have fun.{% endcapture %}
{% include sidebar.html links=page.relatedpages title=new_title %}