You can set up the CMS default pages by store view level in Magento 2.
To set up the Default pages by store view level on your site, You have to follow the given articles with provided steps.
Let’s say we have a website that contains multiple store views based on the language.
Main Website code => base
Main Website Store code => base
Main Website Default Store view code => default (By Default English store)
Main Website Spanish Store view code => us_es (Spanish Store view)
Main Website Spanish Store view code => us_fr (French Language Store view)
There will be two ways to save Default pages in Magento.
- Manually by admin panel
- config.php using code
1) Manually Set up Default Pages for Store View
Now Once you open any store, your homepage will be the same for each store view because you haven’t configured the CMS Homepage for different store views.
You can set up Default CMS pages from the Admin panel.
- Go To the Magento admin panel, log in with your credentials,
- Click on the Left sidebar, Stores -> Settings -> Configuration,
- Now click on the tab, General -> Web -> Default Pages Section,
- You can see the Fields for Default CMS pages.
How to set up default pages for store view?
To set up CMS Pages by store view level, You need to first create a custom CMS page for your Store view. Now change the scope to your store view level from the Top left dropdown.
Just make sure to set the corresponding page to each field in the Default Pages section.
Click on the Save Config button on the Top Right side.
2) Using Code Level in config.php Way,
In this way, Once you set up pages this way, Your field in the admin panel will be locked and you can’t able to modify the field from the admin panel. Next time you must have to modify using config.php only.
'system' => [ 'stores' => [ 'us_fr' => [ 'web' => [ 'default' => [ 'cms_home_page' => 'home', 'cms_no_route' => 'no-route' ] ] ] ] ]
This is the way, You can set up your Default pages.
Just clear the cache using the command line or from the admin panel to see your changes in the browser.