Skip to main content

Got a Custom Drupal Module and Theme? Do Not Give Them the Same Name.

Turns out naming things in Computer Science really _is_ hard.

When you are developing a Drupal website, do not name the theme for your website the same as a custom module. Because things will not work and nothing anywhere will report that something is amiss.

Twice in my career as a Drupal developer I have spent hours on figuring out why "things did not work". Last week I spent the whole afternoon and most of the evening pulling my hair on why my custom Drupal 8 theme would not load its CSS. Squinting at my_theme.libraries.yml and peering over my_theme.info.yml, parsing it char by char 20 times... checking the theme functions to see if I mistyped anywhere... But I couldn't find anything.

Until I realised that the theme had the same folder name as my custom module. And I can't imagine this does not happen to more people? So often when you create a small website, the website has a name, right? And automatically I name the module that will hold the custom logic after the website. Just as I do the theme, because the theme is... the theme for _that_ website. Well, that does not work.

Again, a module and a theme, within the same Drupal website, can not have the same folder name.