Magento: different home page for each theme, but using same store view, and without changing URL?

Magento: different home page for each theme, but using same store view, and without changing URL?

August 29, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: different home page for each theme, but using same store view, and without changing URL?

Magento: Different Home Pages for Each Theme on Same Store View

As an experienced e-commerce developer, I often encounter scenarios where clients need to serve different home pages based on the user’s device type while keeping everything in the same store view. This is a common requirement for mobile-first strategies without changing URLs.

Let me walk you through a practical approach to achieve this using Magento’s built-in capabilities and some custom tweaks to your theme files.

Understanding the Requirement

In your case, you’ve already created a separate mobile theme with distinct CSS, JavaScript, layout, and template files. You’re also utilizing Magento’s matched expressions feature correctly to switch themes based on detected user agents.

What you need now is to display different home pages for these two themes while maintaining a single store view and URL structure.

The Default Approach: Limitations

Magento’s out-of-the-box functionality allows you to set different CMS home pages per store view. However, this requires creating separate stores or views, which may not be ideal if you want to keep everything under one view.

Attempting to set a specific page as the home page for a theme directly in the Magento admin isn’t possible without customization. The core system doesn’t provide a dedicated “Home Page” field at the theme level.

A Workaround: Customizing the Theme

To overcome this limitation, we’ll need to make some modifications to your active theme files. This approach involves pointing the home page URL directly from within the theme’s template file.

Here are the steps:

  1. Find the home page CMS block reference: Open the main template file of your active theme, usually located in app/design/frontend/<YourTheme>/Magento_Theme/templates/page/home.phtml.

  2. Replace the CMS block with direct URL redirection: Search for the code responsible for rendering the CMS home page content. It should look something like this:

<?= $block->getChildHtml('homepage_content') ?>
  1. Add custom logic for device detection and redirection: Replace the existing code with a conditional statement that checks the user agent string. If it matches your mobile user agents, redirect to the mobile home page URL. Here’s an example:
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua, 'Mobile') !== false || strpos($ua, 'Android') !== false) {
    header('Location: https://www.example.com/mobile-home');
    exit();
}
?>

<?= $block->getChildHtml('homepage_content') ?>
  1. Create the mobile home page: In your admin panel, create a new CMS page named “Mobile Home” and assign it the URL of /mobile-home.

  2. Clear cache: After making these changes, clear Magento’s cache to ensure the modifications take effect immediately.

Conclusion

While Magento doesn’t provide an out-of-the-box solution for this scenario, some custom theme tweaks can achieve the desired result without creating separate store views or changing URLs.

Remember that this approach involves direct URL redirection based on user agents, which may not be perfect. It’s always recommended to use proper device detection libraries (like DeviceDetect by Steve Clay) for more accurate results.

As a best practice, never forget to test your changes thoroughly across various devices and browsers to ensure consistent behavior.

If you find yourself needing further assistance or want to explore more advanced solutions, feel free to reach out to our team at Laravel Company. We specialize in Magento development and can provide tailored solutions for your specific needs.

Themes Admin JavaScript CLI

Our network