Is there a way to import Drupal variables into a the twig template? I save a configuration setting using the following code.

$config = \Drupal::service('config.factory')-&gt;getEditable('report.settings');
$config-&gt;set('id', $values['id'])-&gt;save();


Is there a way to use this configuration in my twig template?

I thought about putting PHP code in the template, but it doesn't seem the PHP code added with &lt;?php ?&gt; is executed from the Twig template.
You can't directly use these functions in a Twig file. Instead, you can preprocess the page and store your configuration settings in a variable that is passed to the template file, and display that variable in the template file.

function mytheme_preprocess_page(&amp;$vars) {
  $vars['new_var'] = $config-&gt;get('id');
}


You can render your variable with {{ new_var }}.