Theme structure
A design theme is an important part of the application. This topic describes the file structure of a theme.
Location
Storefront themes are conventionally located under app/design/frontend/<Vendor>/. Though technically they can reside in other directories. For example, built-in themes can be located under vendor/magento/theme-frontend-<theme_code> when a instance is deployed from the Composer repository.
Each theme must be stored in a separate directory:
app/design/frontend/<Vendor>/
├── <theme1>
├── <theme2>/
├── <theme3>
├--...
Components
The structure of a theme directory typically would be like following:
<theme_dir>/
├── <Vendor>_<Module>/
│ ├── web/
│ │ ├── css/
│ │ │ ├── source/
│ ├── layout/
│ │ ├── override/
│ ├── templates/
├── etc/
├── i18n/
├── media/
├── web/
│ ├── css/
│ │ ├── source/
│ ├── fonts/
│ ├── images/
│ ├── js/
├── composer.json
├── registration.php
├── theme.xml
Let's have a closer look at each particular sub-directory.
data-variant=info
data-slots=text
/<Vendor>_<Module>/<Vendor>_<Module>/web/css/.css and/or .less files). General styles for the module are in the _module.less file, and styles for widgets are in _widgets.less./<Vendor>_<Module>/layout/<Vendor>_<Module>/layout/override/base/<Vendor>_<Module>/layout/override/<parent_theme><Vendor>_<Module>/templates/etc/view.xml/i18n.csv files with translations./media/web/web/css/sourcetheme.less file which overrides the default variables values./web/css/source/liblib/web/css/source/lib/web/fonts/web/images/web/js/composer.json<vendor-name>/theme-<area>-<theme-name>./registration.php/theme.xmlFiles
Apart from the configuration file and theme metadata file, all theme files fall into the following two categories:
- Static view files
- Dynamic view files
Static view files
A set of theme files that are returned by the server to a browser as is, without any processing, are called the static files of a theme.
Static files can be located in a theme directory as follows:
<theme_dir>/
├── media/
├── web
│ ├── css/ (except the "source" sub-directory)
│ ├── fonts/
│ ├── images/
│ ├── js/
The key difference between static files and other theme files is that static files appear on a web page as references to the files, while other theme files take part in the page generation, but are not explicitly referenced on a web page as files.
Static view files that can be accessed by a direct link from the storefront, are distinguished as public theme files.
data-variant=info
data-slots=text
/pub/static/frontend/<Vendor>/<theme>/<locale>/css/ directory.Dynamic view files
View files that are processed or executed by the server in order to provide result to the client. These are: .less files, templates, and layouts.
Dynamic view files are located in a theme directory as follows:
<theme_dir>/
├── <Vendor>_<module>/
│ ├── web/
│ │ ├── css/
│ │ │ ├── source/
│ ├── layout/
│ │ ├── override/
│ ├── templates/
├── web/
│ ├── css/
│ │ ├── source/