Sep 29, 2020 in Drupal 8, Snippets

Often we create a custom settings form with stuff like social media url's or addresses. With this snippet you make the variables available in your page.twig.html file. In your mytheme.theme file:

/**
 * Implements hook_preprocess_page().
 */
function MYTHEME_preprocess_page(&$variables) {
  $variables['instagram_url'] = \Drupal::config('mysite.settings')->get('instagram_url');
}

Now, in your page.html.twig file, just use

{{ instagram_url }}

to print the url.