# Including variables in static

**URL:** <https://forum.djangoproject.com/t/including-variables-in-static/1030>\
**Category:** Using Django\
**Created:** [February 1, 2020, 8:10pm UTC](https://forum.djangoproject.com/t/including-variables-in-static/1030 "2020-02-01T20:10:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Figure07](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Figure07](https://forum.djangoproject.com/u/Figure07)\
**Post date:** [February 1, 2020, 8:10pm UTC](https://forum.djangoproject.com/t/including-variables-in-static/1030/1 "2020-02-01T20:10:16Z")

</div>

Hello,

I would like to use a variable name containing a path rather than the path string itself in the format below. For example:  
This is the usual method  
“{% static “imagesfolder/img1.jpg” %}”

However, I have a variable **mypath** defined as  
mypath = “imagesfolder/img1.jpg”  
and would like to include **mypath** in the above format instead of the path string itself.

Could anyone help me out with this ?

Thank you

---

<div class="post-metadata">

**Author:** ![takkaria](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/takkaria/32/288_2.png) [@takkaria](https://forum.djangoproject.com/u/takkaria)\
**Post date:** [February 2, 2020, 1:56am UTC](https://forum.djangoproject.com/t/including-variables-in-static/1030/2 "2020-02-02T01:56:58Z")

</div>

First you need to pass the variable to the template when rendering as context. Then using `{% static mypath %}` should work.

---

<div class="post-metadata">

**Author:** ![Figure07](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@Figure07](https://forum.djangoproject.com/u/Figure07)\
**Post date:** [February 2, 2020, 3:49pm UTC](https://forum.djangoproject.com/t/including-variables-in-static/1030/3 "2020-02-02T15:49:59Z")

</div>

Thank you…will work on that
