node template background image url

See this issue

...two methods are described and both work.

You can do this in twig:

See: regarding twig functions and filters.


Second you can do this in preprocess e.g.:

function HOOK_preprocess_node(&$variables) {
$node = $variables['node'];
$variables['image_url'] = file_create_url($node->field_image->entity->getFileUri());
Then in node template:

However, both these will link to the raw image, no image style, also I tend to think this is theming on the wrong level, i.e. you should be theming the FIELD not the NODE. What I mean is theme at the field preprocess or template level, take a look at this issue regarding field templates and image styles: