Magento 2 separates its frontend design using themes and templates. A theme controls the look and feel of the store, while templates define the structure of pages and blocks using PHTML files.
—
🎨 What is a Magento 2 Theme?
A theme in Magento 2 is a collection of design files (HTML, CSS, JS, images, and templates) that defines the storefront appearance.
Magento 2 Theme Folder Structure:
app/design/frontend/Vendor/theme/ ├── etc/ │ └── view.xml ├── media/ ├── web/ │ ├── css/ │ ├── js/ ├── Magento_Theme/ │ ├── layout/ │ └── templates/ ├── theme.xml ├── registration.php
—
🛠️ Create a Custom Theme
1. Define theme.xml
Vendor Theme Magento/luma media/preview.jpg
—
2. Register the Theme
<?php use Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Vendor/theme', __DIR__);
—
3. Apply the Theme
- Go to Admin Panel → Content → Design → Configuration
- Select your store view and change the theme
- Click Save and clear cache
—
📦 Magento 2 Template Files
Templates are stored in the templates/
folder inside each module or theme.
Example PHTML File:
<?php echo $block->getLogoAlt() ?>
—
📄 Layout Overrides
Layout XML files modify the structure of a page or block.
Override Example:
—
🧩 Template Hints for Debugging
To enable template path hints:
- Admin Panel → Stores → Configuration
- Advanced → Developer → Debug
- Enable template path hints (for developer mode)
—
✅ Best Practices
- Never modify
vendor
theme files directly - Use inheritance to extend the Luma/Blank theme
- Use
pub/static
deployment for performance
—
🧠 Summary
Magento 2 themes and templates offer powerful customization tools. With XML layouts and PHTML templates, you can fully control the appearance and structure of your store frontend.