<p>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.</p>

<p><code>{{ globalSet1.title }}</code>
<code>{{ globalSet1.description }}</code>
<code>{{ globalSet1.variable3 }}</code></p>

CC BY-SA 3.0
2015-06-25T17:58:47.013Z
As a side note, in the case of extending a template, the master template (i.e. "_layout") can access variables declared in the child-template directly — if you are trying for example, to define your 'title', 'description', etc. for the your "_layout" master.
Douglas McDonald
CC BY-SA 3.0
2015-06-25T14:02:16.440Z
2015-06-25T14:02:16.440Z
darylknight
<p>I have a template inside a folder located in <code>/templates</code> that is not related to any entry or section:</p>

<p><strong>/folder/test.html</strong></p>

<pre><code>{% 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 %}
</code></pre>

<p>If I want to create a link to this page, I can use the <code>url()</code> function like this:</p>

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

<p>How can I access the variables declared on this page?</p>

<url><variable><function>
How can I access variables only declared in a template?
# How can I access variables only declared in a template?

(Asked by: username_0 on 2015-06-25)

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 %}

    {{ title }}
    {{ description }}

{% endblock %}

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

How can I access the variables declared on this page?

**Tags:** url, variable, function


---

## 1 answers

### Answer by username_1 on 2015-06-25. Score: 1

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 }}`

> **Comments:**
> **username_2**: As a side note, in the case of extending a template, the master template (i.e. "_layout") can access variables declared in the child-template directly — if you are trying for example, to define your 'title', 'description', etc. for the your "_layout" master.  

---

