codingrow.com
Custom 404 & Maintenance

Create a Custom 404 Page in Magento 2 (Native Guide)

Step-by-step guide to replacing Magento's generic 404 page with a branded, on-site-search-enabled custom 404 page using native tools.

Custom 404 & Maintenance — Create a Custom 404 Page in Magento 2 (Native Guide)

A generic "Whoops, our bad..." screen is a lost opportunity: every broken link or mistyped URL sends visitors to a dead end instead of back into your catalog. Building a Magento 2 custom 404 page natively lets you keep shoppers on-site, reinforce your branding, and even recover a few sales that would otherwise bounce away.

  • Configure a dedicated CMS page to replace Magento's default no-route page
  • Point Magento to that page from the admin, per store view if needed
  • Add branding, a search box and helpful links using native widgets
  • Test, cache-flush and verify the page returns a real 404 status

Step 1: Create the CMS page that will act as your 404

ContentElementsPagesAdd New Page
`Page Not Found`
`404-not-found` (or any unused slug)

Use the WYSIWYG editor to write a short, friendly message and drop in useful shortcuts:

  • A link back to the homepage
  • A link to your main catalog or bestsellers
  • The native CMS Static Block or Catalog Products List widget to show a couple of featured items
Insert the native search widget so visitors can immediately retype what they were looking for instead of leaving the site.

Set @field Enable Page :: Yes and save.

Step 2: Tell Magento to use this page for broken URLs

StoresConfigurationWebDefault Pages
select the CMS page you just created
This setting can be scoped per store view, so a multi-store setup can show a different 404 message (and language) on each storefront.

Save the configuration, then flush the cache.

SystemCache Management
`Flush Magento Cache`

Step 3: Style the page with your theme

Out of the box the CMS page inherits your theme's header, footer and typography, which already looks better than the raw system message. For deeper control:

  • Wrap your content in a custom CSS class and style it in your theme's styles-m.less / styles-l.less files
  • Add a large, bold 404 heading directly in the CMS content for visual impact
  • Keep the message short: one line explaining the page wasn't found, one line inviting action
A large numeral, a short apology line, and a single clear call-to-action button consistently perform better than a wall of text.

Step 4: Override the layout for full template control (optional)

If you need more than a CMS page allows — custom blocks, dynamic product recommendations, a different header — override the layout at theme level.

app/design/frontend/[Vendor]/[theme]/Magento_Cms/layout/cms_noroute_index.xml

Use this file to add or remove blocks around the no-route content, following standard Magento layout XML conventions. This is developer territory: back up your theme and test on staging first.

Layout XML changes require a static content deploy in production mode (bin/magento setup:static-content:deploy) before they appear on the storefront.

Step 5: Verify the page actually returns HTTP 404

Browse to a nonexistent URL on your store, e.g. yourstore.com/this-page-does-not-exist, and check the response headers with your browser's developer tools or a command-line tool.

  • The status code must remain 404 Not Found, even though the content looks custom
  • If you see 200 OK instead, search engines will index the error page as real content — a serious SEO issue
Never redirect broken URLs to your homepage with a 301. That erases the 404 signal and confuses both users and search engines about what went wrong.

Checklist

  • ☐ Dedicated CMS page created and enabled
  • CMS No Route Page set in StoresConfigurationWebDefault Pages
  • ☐ Correct store view scope applied for multi-store setups
  • ☐ Cache flushed after every configuration change
  • ☐ Page verified to return a real 404 HTTP status
  • ☐ Message, search box and homepage link tested on mobile

Common mistakes

Forgetting to flush cache. Configuration and CMS changes can stay invisible behind full page cache. Always flush SystemCache Management after edits.

Leaving the CMS page disabled. A perfectly built page won't show if Enable Page is still set to No — an easy detail to miss after cloning a draft.

Redirecting instead of serving a 404. Sending every broken URL to the homepage with a 301 hides real errors from your SEO reports and from Google Search Console.

Ignoring the maintenance page. A custom 404 solves one half of the error-page experience; the default Magento maintenance screen during deployments still looks generic unless you address it separately.

FAQ

Does a custom CMS 404 page hurt SEO?

No, as long as the server still responds with a 404 status code. Magento's native no-route mechanism preserves that status even when the content comes from a CMS page.

Can I show different 404 pages per store view?

Yes. The CMS No Route Page setting under StoresConfigurationWebDefault Pages can be scoped to a specific website, store, or store view.

Why isn't my new 404 page showing up?

Usually a caching issue. Flush the Magento cache, check the CMS page is enabled, and confirm you saved the configuration at the correct scope.

Should the 404 page and the maintenance page look the same?

They serve different moments (an error vs. planned downtime), but keeping consistent branding — logo, colors, tone — across both reassures visitors that the site is trustworthy rather than broken.

A faster alternative

Building this natively works well, but keeping the 404 page, the maintenance page, backgrounds, fonts and accent colors in sync across a theme redesign means repeating the same manual steps every time.

The Custom 404 & Maintenance module adds a single admin configuration screen where you set the title, message, search box, button label, logo, background (color, gradient or image with darkening) and accent colors for both the 404 page and the maintenance page together — with a live preview before you save.

Custom branded 404 page with logo, message, search box and back-to-home button
Custom branded 404 page with logo, message, search box and back-to-home button
Admin configuration panel for the 404 page with title, message and button label fields
Admin configuration panel for the 404 page with title, message and button label fields

It also ships a CLI command to regenerate the pages across store views, so the same branded experience appears instantly whether a visitor hits a broken link or your store is in scheduled maintenance.

Questions & Answers

No questions yet — be the first to ask.

Ask a question

Public. Shown only after moderation. No spam.