How to set page variable from custom module
As far as I can tell, this should be handled in the custom theme, not in the custom module.  This is because the module really has no idea how a custom theme wants to render stuff.

In any case, in the custom theme, the only way I can figure out how to make the data available is to register a hook_preprocess() function in the theme, check the hook that's called, and declare a static variable that sticks around until it can be injected later on.

The custom module's "promt_program" hook will be called earlier than the theme's "page" hook. I'm pretty sure that will always be true.  So, we grab the location_id and then inject it later on.

This preprocess function will get called many, many times, so it seems important to make it thin.

function cob_preprocess(&amp;$vars, $hook)
{
    static $location_id = null;

    switch ($hook) {
        case 'promt_program':
            if (!empty($vars['program']['location_id'])) { $location_id = $vars['program']['location_id']; }
        break;

        case 'page':
            if ($location_id) {
                $query = \Drupal::entityQuery('node')
                    -&gt;condition('status', 1)
                    -&gt;condition('type', 'location')
                    -&gt;condition('field_promt_id', $location_id);
                $nids  = $query-&gt;execute();
                if ($nids) {
                    $vars['node'] = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load(current($nids));
                }
            }
        break;
    }
}