Creating custom settings/variables for site
To save custom configuration you probably want to use ConfigFormBase, the code would look something like this.

class SocialSettingsForm extends ConfigFormBase {
  ...

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'social.settings', // The name of the config you want to edit
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    $this-&gt;config('social.settings')
      -&gt;set('facebook', $form_state-&gt;getValue('facebook'));
  }
}


Then everywhere, you can use the config factory of the Drupal global object to get the config like this.

function some_preprocess_function(&amp;$variables) {
  $facebook = \Drupal::config('social.settings')-&gt;get('facebook', 'default_value_if_no_value_is_set');
}


Note the above approach is centered around how you would do it in a module, saving and getting configuration. You should also note that it's best practice to define the configuration a module provides in a yml file located in module_folder/config/schema/module_name.schema.yml. I'm not 100% sure what the file is actually used for, as it's possible to save configuration not defined in the config file and all other features seem to "work" just fine without it.