codingrow.com
Auto Switch Home

Different Homepage for Guests vs Logged-In Users in Magento 2

A step-by-step native Magento 2 method to display a different homepage content to guests and logged-in customers without custom code.

Many store owners want to greet returning, logged-in customers with a personalized homepage while guests see a generic landing page. This guide shows how to build a different homepage for logged-in customers Magento 2 setups using only native CMS widgets, customer group rules, and cache settings — no custom module required.

  • Create two homepage content variants tied to customer groups
  • Configure native Widgets to auto-switch content by login status
  • Avoid Full Page Cache pitfalls that break the switch
  • Test and validate the setup across guest and logged-in sessions

Step 1: Prepare two CMS static blocks

Before touching layout settings, build the two content pieces you want to alternate.

ContentElementsBlocks
create a block titled `Homepage Content - Guest`
create a second block titled `Homepage Content - Logged In`

Fill each block with the content, banners, or Page Builder sections meant for that audience.

Keep the Block ID (Identifier) short and descriptive, e.g. home-guest and home-logged-in — you'll need to reference them later when checking output.

Step 2: Locate (or create) your Home Page CMS page

ContentElementsPages
open the page currently set as your store's homepage
Confirm which page is the actual homepage under StoresConfigurationGeneralWebDefault PagesCMS Home Page. This is the page you'll edit.

Remove any static "welcome" content block that currently applies to everyone — you'll replace it with two conditional widgets instead.

Step 3: Add the guest-only widget

Native Magento widgets support a Customer Groups restriction, which is the key to this whole setup.

ContentElementsWidgets
set `Type` to `CMS Static Block`
choose your active storefront theme

On the next screen:

select `Homepage Content - Guest`
check only `NOT LOGGED IN`
set to `Specified Page` and choose your Home Page CMS page
choose the content container matching where you want it to render (e.g. `Main Content Area`)

Save the widget.

Container names can vary by theme — inspect your theme's default.xml layout file if Main Content Area doesn't produce the expected result.

Step 4: Add the logged-in widget

Repeat the same process for registered customers.

ContentElementsWidgetsAdd Widget
select `Homepage Content - Logged In`
check `General`, `Wholesale`, or whichever groups apply to logged-in accounts (exclude `NOT LOGGED IN`)
same Home Page CMS page, same container

Both widgets now sit in the same spot, but Magento only renders the one matching the visitor's group.

If you have multiple logged-in tiers (VIP, Wholesale, Retail), duplicate this widget per group and assign different blocks to personalize even further.

Step 5: Handle Full Page Cache correctly

This is the step most tutorials skip — and the most common reason the switch "doesn't work" in production.

Magento's built-in Full Page Cache varies pages by customer group automatically via the X-Magento-Vary cookie, but only when the page is marked cacheable and the customer session is properly detected. If you're behind a CDN or Varnish with aggressive caching rules, guest and logged-in visitors might see a stale mixed version.

To verify:

StoresConfigurationAdvancedSystemFull Page Cache
confirm whether `Built-in Application` or `Varnish Caching` is selected

If using Varnish, check that your varnish.vcl respects the X-Magento-Vary cookie — this is generated by default in Magento's sample VCL files, so custom edits are the usual culprit when it breaks.

Step 6: Clear cache and reindex

SystemCache Management
click to clear all cache types

Run from CLI if you have server access:

bin/magento cache:flush

Widget layout changes are cached under the layout and full_page cache types. If content doesn't switch after saving, flushing cache is almost always the fix.

Step 7: Test both scenarios

  • Open an incognito/private browser window and visit your homepage as a guest.
  • Log in with a test customer account in a separate session and reload the homepage.
  • Confirm each session shows the correct block content.
Use two different browsers (or one regular + one incognito) side by side so you can compare guest vs logged-in rendering instantly without logging in and out repeatedly.

Checklist

  • ☐ Two CMS static blocks created (guest and logged-in content)
  • ☐ Home Page CMS page identified via Default Pages configuration
  • ☐ Guest widget created with NOT LOGGED IN customer group restriction
  • ☐ Logged-in widget created with the correct customer groups
  • ☐ Both widgets assigned to the same container on the Home Page
  • ☐ Full Page Cache / Varnish configuration verified for X-Magento-Vary
  • ☐ Cache flushed and layout re-tested in two sessions
Revisit this checklist any time you add a new customer group or membership tier, since new groups won't automatically inherit personalized content.

Common mistakes

Both blocks show at once, stacked on top of each other.

This usually means the Customer Groups restriction wasn't saved correctly on one of the widgets, or both widgets were accidentally assigned to All Groups. Re-edit each widget and confirm the exclusive group selection.

Skipping the exclusive group check is the single most common cause of overlapping content — always verify each widget's Customer Groups selection before moving on.

Content doesn't change even after logging in.

Flush the full_page cache type specifically, and check whether a CDN in front of Magento is caching the HTML independently of Magento's own cache headers.

Widget shows on every page, not just the homepage.

Double-check the Layout UpdatesDisplay On setting — it must be Specified Page with the exact Home Page CMS page selected, not All Pages.

Wholesale or B2B customers see the guest version.

Make sure every customer group that should see personalized content is explicitly checked on the logged-in widget; unchecked groups fall back to no widget at all if they don't match the guest widget's exclusion either.

FAQ

Can I do this without touching customer groups at all?

Not cleanly. The Customer Groups field on the Widget is the native mechanism Magento provides to differentiate guest vs. logged-in content without custom PHP code, so at minimum you need the default NOT LOGGED IN group and one logged-in group configured correctly.

Will this work with Varnish or a third-party CDN?

Yes, as long as the caching layer respects Magento's X-Magento-Vary cookie. If you're using a CDN that strips cookies before caching, you'll need to configure a bypass rule for the homepage or exclude it from edge caching.

When configuring a CDN bypass rule, scope it narrowly to the homepage URL only, to avoid disabling caching benefits sitewide.

Can I extend this to show different homepages per store view instead of customer group?

Yes — widgets also support a Store View scope on the same screen used for Customer Groups. You can combine both conditions if you need per-store-view AND per-customer-group logic.

Does this affect SEO or crawlability?

Search engine bots are treated as guests (not logged in), so they will always see the guest-facing content, which is generally what you want for consistent indexing.

A faster alternative

Setting up widgets, customer group rules, and verifying cache behavior works well, but it takes real configuration time and ongoing maintenance whenever you add new groups or content variants. If you'd rather manage homepage switching visually — by device, store view, or customer segment — without juggling multiple widgets and cache edge cases, take a look at Auto Switch Home, a dedicated extension for automatically switching Magento 2 homepages.

Extensions like this can also handle edge cases such as new customer groups or device-based rules without manual widget duplication.

Questions & Answers

No questions yet — be the first to ask.

Ask a question

Public. Shown only after moderation. No spam.