:::: MENU ::::

Magento 2 set homepage

Magento 2 set homepage

Today we discuss about Magento 2 set homepage.This tutorial include how to change or set homepage in system configuration program and how to change or set homepage from admin panel system configuration.There are two way to set home page one is from admin panel other is set homepage programmatically. So let start with our example

Set homepage from Admin Panel

Login to admin panel.

Store > Setting > configuration > Web Tab > Default Page

Select your desired page from dropdown.

Field CMS Home Page

Magento 2 set homepage

Set homepage from programmatically

Just inject the class \Magento\Config\Model\ResourceModel\Config $_resourceConfig and set value for web/default/cms_home_page to desired page ‘youridentifier’.

public function __construct(\Magento\Config\Model\ResourceModel\Config $_resourceConfig)
        $this->_resourceConfig = $_resourceConfig;

        $this->_resourceConfig->saveConfig('web/default/cms_home_page', 'youridentifier', 'default', 0);
Author: Qaisar Satti
Category: Magento 2
Last Modified: August 10, 2018

So, what do you think ?

You must be logged in to post a comment.