Walmart Embraces Amazon MCF: A New Era of Cross-Platform Fulfillment for eCommerce
Walmart Embraces Amazon MCF: A New Era of Cross-Platform Fulfillment for eCommerce
Design in Magento 2.0 is entirely different as compared to Magento 1 due to its architecture and the introduction of .less files. But this blog will make everything easy for you and will explain in detail the procedure of creating custom theme and design in Magento 2.0 using LESS. So, keep reading the blog till the end to get to know the correct process of creating your custom theme in Magento 2.
Now let us advance step by step towards Magento 2 custom theme creation.
Start with creating your theme at the following location:
<your Magento installation dir>/app/design/frontend/<vendor>/<theme>
vendor: Your Organization Name / Any Unique Name.
theme: Your Theme Name.
After creating a directory for your theme, you must create theme.xml containing at least the theme name and the parent theme name (if the theme inherits from one). Optionally you can specify where the theme preview image is stored. Add or copy from an existing theme.xml to your theme directory.
app/design/frontend/<Vendor>/<theme>
Configure it using the following example:
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd"> <title>New theme</title> <!-- your theme's name --> <parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme --> <media> <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image --> </media> </theme>
Magento 2 default themes are distributed as Composer packages. To distribute your theme as a package, add a composer.json file to the theme directory and register the package on a packaging server. A default public packaging server is https://packagist.org/. “composer.json” provides theme dependency information.
Example of a theme composer.json:
{ "name": "magento/theme-frontend-luma", "description": "N/A", "require": { "php": "~5.5.0|~5.6.0|~7.0.0", "magento/theme-frontend-blank": "100.0.*", "magento/framework": "100.0.*" }, "type": "magento2-theme", "version": "100.0.1", "license": [ "OSL-3.0", "AFL-3.0" ], "autoload": { "files": [ "registration.php" ] } }
To register your theme in the system, add a registration.php file in your theme directory with the following content:
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::THEME, 'frontend/<Vendor>/<theme>', __DIR__ );
Product image sizes and other properties used on store-front are configured in the view.xml configuration file. It is required for a theme, but is optional if it exists in the parent theme.
If the product image sizes of your theme differ from those of the parent theme, or if your theme does not inherit from any theme, add view.xml using the following steps:
... <image id="category_page_grid" type="small_image"> <width>250</width> <height>250</height> </image> ...
Your theme will likely contain several types of static files: styles, fonts, JavaScript and images. Each type should be stored in a separate sub-directory of web in your theme folder:
app/design/<area>/<Vendor>/<theme>/
├ web/
│ ├ css/
│ │ ├ source/
│ ├ fonts/
│ ├ images/
│ ├ js/
In the …/<theme>/web/images you store the general theme related static files. For example, a theme logo is stored in …<theme>/web/images. It is likely that your theme will also contain module-specific files, which are stored in the corresponding sub-directories, like …/<theme>/<Namespace_Module>/web/css and similar.
If you want to include .less files in your theme then you can do it by the following steps:
First of all, you need to add your file. So for this you just need to add the simple css file from the following location,
app/design/frontend/<vendor>/<theme>/Magento_Theme/layout/default_head_blocks.xml Example: <css src="css/custom.css" />
Now you will be thinking that the blog is for including .less files so why we are including .css files. So, the answer is Magento’s built in LESS preprocessing system. Whenever we add any css file in the layouts, LESS preprocessor does the following:
You just need to add the file with .less extension. It will be added and preprocessed by Magento when you deploy the static content.
Here we would like to clear out one confusion that Magento 2.0 supports both: normal Css files and LESS. You can either use LESS to simplify the management of complex CSS files or can directly include a css file and write your css upfront. But using LESS is suggested more, as otherwise you are not using one of the many benefits of Magento 2.
Magento 2 supports LESS, a CSS per-processor that simplifies the management of complex CSS files. To define styles of a Magento store, you can use both – CSS and LESS style sheets.
Magento 2.0 application provides a built-in LESS UI library, which you can optionally extend.
To customize store-front styles, you need to create a custom design theme. Then you can use one of the following approaches:
Conventionally, CSS and LESS files are stored only in themes. Module directories do not contain any default styles.
web/css/source– this subcatalog contains the LESS configuration files that trigger mixins from Magento UI library
Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, extendible and as per your theme. We use it as it allows us to use variables, mixins, functions and mathematical operations for creating our CSS files.
The Best Practice to use the LESS is to Create a new theme, which inherits from the Blank theme as it saves your time and creates an easier experience for developers and designers.
WAIT : Not able to work out your .less via GRUNT, don’t worry there is also way around to it, find it under topic “Compiling Your Theme Files.”
We have already told you how you will add a custom css to your theme, now how will a custom css generate from a less file and to do this we would like to demonstrate it through an example:
Step 1: Include a Css file for your custom changes and name it any thing according to your requirement, for example we name it: custom.css
Step 2: Now inside your theme under web/css/ create a file names custom.less i.e. web/css/custom.less
Step 3 : Now inside the web/css/ and parallel to the custom.less create a custom directory which will contain different files in which you have made your custom changes according your theme and even those files which you need to create new, this can contain as many files as you require to make your changes.
It should look like: web/css/custom/_anyfile.less
For Example:
If you need to declare new sets of variables and also make some specific changes to the header section you can create the files like:
_variables.less
_header.less
Step 4 : And now you can import your files into your custom.less using @import
Example:
@import “custom/_variables.less”;
@import “custom/header.less”;
Step 5: And now when you compile your less file you will find that all the codes from different files onside the custom directory have sampled down into one single file which is custom.css
If You have .less files in your theme, then you have to compile those files to generate the corresponding .css files. You can do it via multiple ways like using grunt etc. But we’ll tell you the most common and easiest way which is by “Static Content Deploy“. Whenever you make changes in your .less file then you have to flush the existing static content of your theme, which resides at the following location:
>><your Magento install dir>/pub/static/frontend/<vendor>/<theme>/
You have to delete all the content inside this directory. Then Deploy the static content by using following command:
>>php bin/magento setup:static-content:deploy
Once you deploy your static content then your .less file will be compiled at the following location:
>><your Magento install dir>/pub/static/frontend/<vendor>/<theme>/<locale>/css
Both the files i.e. complied .less file as well as its corresponding .css file will be created inside that directory.
NOTE: Every time you make changes in your .less file then you have to repeat the whole process.
With this we come to the end of custom theme creation in Magento 2. Please share your reviews and suggestions regarding this blog. We would be happy to hear from you.
For more details please visit the given links:
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/bk-frontend-dev-guide.html
http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css-preprocess.html
Walmart Embraces Amazon MCF: A New Era of Cross-Platform Fulfillment for eCommerce
Order Management Redefined: A Centralized Solution for Amazon Sellers
Maximizing TikTok Shop’s Regional Compatibility for US, UK, and EU Markets
Understanding U.S. Tariffs in 2025: What Sellers Need to Know and Do
Walmart’s Search Algorithm Decoded: How to Rank Higher & Sell More
TikTok Gets a 75-Day Reprieve in the USA as Trump Signals Hope for a Deal
TikTok Shop Introduces Category-Based Benchmarks for Product Listings – What Sellers Need to Know
Amazon FBA vs. FBM: Which Fulfillment Method Is Right for You?
Amazon Launches Another AI Tool for Sellers: AI Generated Product Enrichment
Top 10 Selling Items on eBay in 2025
Amazon launches AI Powered ‘Interests’ Feature to Improve Shopping Experience
Is TikTok Staying in the US? The State of TikTok Ban
Best Buy coming back to the US, Marketplace Relaunch and New Opportunities in Store!
Miravia PrestaShop Connector: Built for Smart Sellers
Walmart Launches “Wally”, AI Assistant For Merchants
TikTok Shop to Start Business in Germany, France, and Italy
TikTok Shop Surges as Americans Spend $700 Annually, Defying Regulatory Pressures
Amazon’s Longest Prime Day Ever: What You Need to Know
eCommerce Growth in the Netherlands: A 5% Surge in 2024 with Bright Prospects Ahead
CedCommerce Launches Shopee & Lazada Integration for WooCommerce on WordPress.com