Hello Magento Friends,

In this blog, I will explain the steps to Set a Theme on a Specific Page in Magento 2. 

Magento 2 allows you to set a global theme for your entire store. But there might be cases where you want to apply a different theme to a specific page. This could be for promotional campaigns, seasonal changes, or any other reason.

Let’s go through the process of setting a theme on a specific page in Magento 2.

Steps to Set a Theme on a Specific Page in Magento 2:

Step 1: Create a routes.xml file in the path given below

{{magento_root}}\app\code\Vendor\Extension\etc\frontend\routes.xml

Then add the code as follows.

Step 2: Create a controller file in the following path

{{magento_root}}\app\code\Vendor\Extension\Controller\Index\Index.php

Then add the code as given below.

Step 3: Create a layout file at the below-mentioned path

{{magento_root}}\app\code\Vendor\Extension\view\frontend\layout\frontroute_index_index.xml

Add the following code-snippet

Step 4: Create a template file at the path mentioned below

{{magento_root}}\app\code\Vendor\Extension\view\frontend\templates\index\index.phtml

Now, add the code as given below.

Step 5: Create a Block file at the below path

{{magento_root}}\app\code\Vendor\Extension\Block\Index\Index.php

Then add the below-mentioned piece of code.

Step 6: Create an events file at the following path

{{magento_root}}\app\code\Vendor\Extension\etc\events.xml 

Then, include the code as follows.

Step 7: Create an observer class file at the following path

{{magento_root}}\app\code\Vendor\Extension\Observer\SetThemePage.php

And the below-mentioned code

Step 8: Finally, run the below commands.

Conclusion:

Setting a theme on a specific page in Magento 2 is a powerful way to create unique experiences for your customers. By following the steps outlined in this blog post, you can effectively apply different themes to specific pages and enhance the visual appeal and functionality of your Magento 2 store.

You may also like to check out below blogs –

How to Apply Admin Theme in Magento 2?

How to Create Child Theme in Magento 2

Easy Method to Apply The Default Theme In Magento 2

How to Change Theme In Magento 2

If you face any difficulty or errors while executing the above steps, kindly let me know through the comment box, and I will quickly help you out to get rid of the error. Share the tutorial to set a theme for a specific page in Magento 2 with your friends, and stay in touch with us.

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]