Static resource URL in Drupal 8 theme I'm trying to place an image using a local resource in theme. Using the site url like

drupal.localhost/themes/customtheme/images/image.png


does give me access denied error. I understand that Drupal should generate a public url for the image, but how to ask Drupal to do so from the theme while still using relative URLs in src tag of img ?

edit: Changed question, made more clear
Check out file_create_url() function:

Example of usage in a preprocess hook:

$variables['image'] = file_create_url($variables['directory'] . '/images/image.png');


Example of usage in a twig template:

 &lt;img src="{{ file_url(directory ~ '/images/image.png') }}"/&gt;