Magento - Different homepage for mobile vs. desktop

Magento - Different homepage for mobile vs. desktop

October 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Different homepage for mobile vs. desktop

Different Homepages for Mobile and Desktop: A Comprehensive Guide for Magento

When it comes to e-commerce websites, providing an optimal user experience across different devices is crucial. This often involves serving different content or layouts for mobile visitors compared to desktop users. If you’re using the Magento platform, achieving this capability requires a combination of proper configuration and custom development.

Understanding the Current Approach: Switching Themes

Your current strategy of switching themes based on user agent via the System -> Configuration -> General/Web section can provide some level of control over the mobile experience. However, it has its limitations. This approach mainly affects the visual styling and layout components rather than fundamentally altering the content served to users.

Limitations of the Existing Method

The tutorial you mentioned (which I won’t link here for clarity) focuses on theming, which is a great starting point but doesn’t address your primary question: pulling different CMS pages for the homepage based on device type. This approach involves creating a separate theme for mobile devices and then linking that theme to specific user agents.

While this can help create a more optimized layout for smaller screens, it doesn’t allow you to serve completely different content from your standard home page.

The Ideal Solution: Custom Controller Overrides

To achieve your goal of serving distinct CMS pages for the homepage based on device type, we’ll need to override the default Magento homepage controller. This involves creating a custom module with a new controller that inherits from the existing one but provides different behavior based on the user agent.

Here’s a high-level overview of the steps involved:

  1. Create a Custom Module: Start by creating a new module in your app/code directory, following the standard Magento module structure (e.g., Company_MobileHomepage).

  2. Override the Default Controller: In your new module, create an override for the catalog controller that handles the homepage action (CatalogController.php). Make sure to extend the parent class correctly.

  3. Check the User Agent: Within the overridden indexAction method, you can check the user agent string using PHP’s $_SERVER global variable or Magento’s built-in functions like Mage::helper(‘core’)->getRequest()->getAgent().

  4. Serve Different Content Based on Device Type: If a mobile user agent is detected (you may need to define your own detection logic or use an existing library), you can fetch the desired CMS page content differently than for desktop users.

  5. Assign the Custom Controller: Finally, configure Magento to use your new controller instead of the default one by updating the router configuration in your module’s etc/config.xml file.

Best Practices and Tips

  • Always ensure that your customizations are properly documented and version-controlled.
  • Consider using a dedicated mobile theme for styling rather than relying on in-page CSS modifications.
  • Test extensively across different devices, browsers, and user agents to ensure consistency.
  • Monitor performance and load times carefully when serving heavy content or images.

Conclusion

Creating different homepages for mobile and desktop users in Magento requires a combination of careful configuration and custom development. By overriding the default homepage controller, you can serve distinct CMS pages based on device type.

While this process involves some complexity, it provides the foundation for creating a truly optimized multi-device experience for your storefront. As always, I recommend consulting with an experienced Magento developer or reaching out to Laravel Company for professional assistance in implementing these changes securely and efficiently.

Performance Themes Configuration

Our network