“This is the real secret of life -- to be completely engaged with what you are doing in the here and now. And instead of calling it work, realize it is play.” ― Alan Watts

Create adminimal sub-theme - Drupal 8

July 11, 2020

There comes a time when you need to override an administration theme such as Adminimal.

Sometimes this is not as simple as one might hope.

I found this thread on Drupal.org, and noticed that the solution documented there, wasn't quite working, there were some regions missing in the adminimal theme such as the secondary links.

The solution is to copy the config/optional files from the adminimal theme into your subtheme, this needs to be done prior to installing your sub-theme.

You should also rename the files accordingly, using your sub-theme machine name, so if you sub-theme is called 'adminimal_subtheme' then rename the files to:

  • block.block.adminimal_subtheme_breadcrumbs.yml
  • block.block.adminimal_subtheme_content.yml
  • block.block.adminimal_subtheme_help.yml
  • block.block.adminimal_subtheme_local_actions.yml
  • block.block.adminimal_subtheme_login.yml
  • block.block.adminimal_subtheme_messages.yml
  • block.block.adminimal_subtheme_page_title.yml
  • block.block.adminimal_subtheme_primary_local_tasks.yml
  • block.block.adminimal_subtheme_secondary_local_tasks.yml

You also need to edit each individual file to replace the use of 'adminimal_theme' with your sub-theme name.

Original file

langcode: en
status: true
dependencies:
  module:
    - system
  theme:
    - adminimal_theme
id: adminimal_theme_breadcrumbs
theme: adminimal_theme
region: breadcrumb
weight: 0
provider: null
plugin: system_breadcrumb_block
settings:
  id: system_breadcrumb_block
  label: Breadcrumbs
  provider: system
  label_display: '0'
visibility: {  }

After replacing with my sub-theme name

langcode: en
status: true
dependencies:
  module:
    - system
  theme:
    - adminimal_subtheme
id: adminimal_subtheme_breadcrumbs
theme: adminimal_subtheme
region: breadcrumb
weight: 0
provider: null
plugin: system_breadcrumb_block
settings:
  id: system_breadcrumb_block
  label: Breadcrumbs
  provider: system
  label_display: '0'
visibility: {  }

Then the final and vital stage before installing your sub-theme is to add the regions from the adminal theme into to your subtheme info.yml file.

Here is my info.yml file

name: Adminimal subtheme
type: theme
description: Sub-theme of adminimal
core: 8.x
base theme: adminimal_theme

libraries:
  - adminimal_subtheme/global-styling

regions:
  header: 'Header'
  pre_content: 'Pre-content'
  breadcrumb: Breadcrumb
  highlighted: Highlighted
  help: Help
  content: Content
  page_top: 'Page top'
  page_bottom: 'Page bottom'
  sidebar_first: 'First sidebar'
regions_hidden:
  - sidebar_first

 

I have also created a Git repository here.