Search by

yireo / magento2-theme-by-route

yireo

Assign a specific theme to specific routes

Package info

github.com/yireo/Yireo_ThemeByRoute

Type:magento2-module

pkg:composer/yireo/magento2-theme-by-route

Fund package maintenance!

yireo

www.paypal.me/yireo

Statistics

Installs: 548

Dependents: 0

Suggesters: 1

Stars: 2

Open Issues: 0

1.1.3 2026-11-26 01:39 UTC

This package is auto-updated.

Last update: 2026-11-29 21:06:46 UTC


README

Magento version PHP version License Latest Version

Magento 2 module to allow a file app/etc/theme-by-route.json to determine which theme needs to be loaded for which route.

Installation

composer require yireo/magento2-theme-by-route
bin/magento module:enable Yireo_ThemeByRoute

Configuration

Create a file app/etc/theme-by-route.json similar to the following:

{
  "Loki/luma": [
    "cms/index/index"
  ]
}

Now, the Loki/luma theme is applied to the homepage (cms/index/index), while all other pages keep the theme that is configured for the store.

Each entry in the list of pages is matched against the current request in three ways:

  • Route name (an entry without a slash, like checkout or customer): applies to all pages of that route.
  • Full action name (like cms/index/index or cms_index_index): applies to a single controller action. Matching is case-insensitive.
  • URL path (like about-us or customer/account/login): matched against the path of the URL, without the base URL, the store code and the query string.

If you want to control under which circumstances which theme is applied, there is an advanced syntax as well:

[
  {
    "scope_type": "website",
    "scope_code": "base",
    "theme": "Loki/luma",
    "pages": [
      "cms/index/index"
    ]
  }
]

The scope_type is either website, group or store, and scope_code is the code of that website, store group or store view. All entries that match the current scope are combined. When multiple themes match the same request, the first theme in the file wins.

Notes

  • After changing app/etc/theme-by-route.json (or the Enabled setting under Stores > Configuration > Advanced > System > Yireo ThemeByRoute), flush the Full Page Cache: bin/magento cache:clean full_page.
  • Design changes (scheduled designs) and user-agent design exceptions are applied after this module and therefore take precedence.
  • Make sure that the static content of every theme in the file is deployed.

Current status

Static Tests Unit Tests Integration Tests Playwright DI Compilation