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.
Fill each block with the content, banners, or Page Builder sections meant for that audience.
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
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.
On the next screen:
Save the widget.
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.
Both widgets now sit in the same spot, but Magento only renders the one matching the visitor's group.
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.
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:
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
Run from CLI if you have server access:
bin/magento cache:flush
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.
Checklist
- ☐ Two CMS static blocks created (guest and logged-in content)
- ☐ Home Page CMS page identified via
Default Pagesconfiguration - ☐ Guest widget created with
NOT LOGGED INcustomer 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
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.
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 Updates›Display 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.
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.



