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

 * Implements hook_install().
function myprofile_install() {
  \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'My Site')->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.

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.