Setting site name in installation profile I'm creating an installation profile. Currently, hook_install() contains only this:

/**
 * Implements hook_install().
 */
function myprofile_install() {
  \Drupal::service('config.factory')-&gt;getEditable('system.site')-&gt;set('name', 'My Site')-&gt;save();
}


Still, after installation is completed (using Drush) the site name is always "Drupal".

The code works if I paste it into Devel's Execute PHP after the site is installed.

Another option I tried is overriding system.site.yml within my profile, which won't load because I wrote uuid: ''. (I don't know how to leave the already-generated UUID.)

How can I set the site name during installation in my custom profile? 



EDIT: I found out the following:


The site name gets overwritten when the install configuration form is submitted by Drush, using the values provided by Drush (including site name)
The installation profile must provide a translation of the site information for each enabled language (I have more than one). I assume I'll do this with the core module Configuration Translate.
The solution was to use hook_install_tasks. 

The source of the issue was that Drush was filling in the install configuration form during the installation process. Because the form comes after the profile's hook_install, it will override whatever configuration we write in hook_install.

Using hook_install_tasks will work by defining a new install task for setting our preferred configuration, which Drupal will run after submitting the configuration form. See function install_tasks() in core/includes/install.core.inc, line 716.