Twig - 呈现一些变量(常量)?

I need some variables(constant) in my project:

path_to_root path_to_images

I would like to make it without php, just Twig, so i create main.twig:

main.twig:

{% set path_to_root = "/some_folder" %}
{% set path_to_images = "/some_images" %}

In second template i extends by main.twig, so

template.twig

{% extends "main.twig" %}

{% block some_block %}
<a href="{{ path_to_root }}/link.php">some_text</a>
<img src="{{ path_to_images }}/image.png" />
{% endblock %}

Yes, it works, bu my question: Is this good way for having main.twig and in child extends with main? In each file of templates will i must extends with main.twig?

Sorry for my english :(

Not sure about other php files but the images should go in the assets folder which then you can import using

<img src="{{ asset('path/to/folder/image.png') }}" />