How can I access variables only declared in a template? I have a template inside a folder located in /templates that is not related to any entry or section:

/folder/test.html

{% extends '_layout' %}

{% set title            = 'myTitle' %}
{% set description      = 'myDescription' %}
{% set variable3        = 'hello' %}


{% block content %}

    &lt;h1&gt;{{ title }}&lt;/h1&gt;
    &lt;p&gt;{{ description }}&lt;/p&gt;

{% endblock %}


If I want to create a link to this page, I can use the url() function like this:

&lt;a href="{{ url('folder/test') }}"&gt;test&lt;/a&gt;


How can I access the variables declared on this page?
I don't think you can. I think the best way to access 'unattached' variables is to create a global field set and attach fields to it. That way you'll be able to access them anywhere.

{{ globalSet1.title }}
{{ globalSet1.description }}
{{ globalSet1.variable3 }}