Part – 2: Creating a custom Drupal 8 Theme

Published on : April 27, 2026

Author:

Category: Uncategorized


Here are two main approaches to create a D8 theme.

  1. Create a sub theme using Classy as a base theme – minimum Drupal Classes
  2. Create a custom theme – No Classes

 

D8 have changes theme file structure:

  1. Core themes: core/themes ( example – bartik, classy, seven ect). See below imagecore theme
  2. Contrib and Custom: theme/ (example – my-theme)

custom theme

Good practice:

  • Contrib themes: themes/contrib/
  • Custom themes: themes/custom/

 

Drupal 8 changed .info to .info.yml

 

Create new theme:

Install a fresh copy of Drupal 8. Drupal 8 required OPcache. To enable it for localhost, just open “php.ini”. Search for “opcache.enable”. Enable it and add below line top of this line.

zend_extension=php_opcache.dll.

Final code –

zend_extension=php_opcache.dll

opcache.enable=1

Now go to you-project-name/themes create a folder named custom. Create you theme folder into custom folder. Suppose my D8 theme name my-theme. So, my theme directory will be – my-project-name/theme/custom/my-theme.

 

Drupal 8 theme requires two .yml file.

  1. Theme-name.info.yml. here we will declare theme name, description, type, package and core..info.yml
  2. Theme-name.libraries.yml. here we will add css, js and dependencies libraries as like below

lib

Now create a page.html.twig file and past you HTML here. See below image –

tpl

Now place your blocks to commented regions.

2


Leave a Reply

Your email address will not be published. Required fields are marked *