How to create a 404 page - Page Not Found

This tutorial is over a year old and may not apply to your version of Concrete CMS.
Apr 29, 2016

Creating an Error 404 Page

If your Theme does not include a file named page_not_found.php, you can create your own.

Create a page_not_found.php

Upload the file to application/themes/CustomThemeFolder (or where your theme is)

Then add the following

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>

<main>
    <div class="container">
        <div class="row">
            <div class="col-sm-9 col-sm-offset-3">
                <div class="jumbo">
                    <h1><?php echo t('404 Error')?></h1>
                    <p><?php echo t('Page not found.')?></p>
                </div>
            </div>
        </div>
    </div>
</main>

<?php  $this->inc('elements/footer.php'); ?>

If you want to make your 404 page editable with a search, use the following instead.


<?php defined('C5_EXECUTE') or die("Access Denied."); $this->inc('inc/header.php'); ?> <div id="main-content" class="main-container"> <div class="main-content-inner clearfix"> <main role="main"> <div class="container"> <div class="row"> <div class="col-sm-8 col-sm-offset-2"> <main role="main"> <article> <?php $a = new Area('Main'); $a->enableGridContainer(); $a->display($c); ?> </article> </main> <div class="jumbo"> <h1><?php echo t('404 Error')?></h1> <p><?php echo t('Page not found, so please search.')?></p> <?php $bt = BlockType::getByHandle('search'); $bt->controller->title = t('Search'); $bt->controller->buttonText = t('Search'); $bt->render(); ?> </div> </div> </div> </div> </main> </div> </div> <?php $this->inc('inc/footer.php'); ?>

Find out how to optimize you 404 error page.

Recent Tutorials
Setting addon/theme version compatibility in the marketplace
Jan 9, 2024

For developers worn out with setting the latest addon or theme version manually across too many core versions, here is a JavaScript bookmarklet to do it for you.

How to get the locale of a page
Jan 8, 2024
By mandako.

Now, why don't we just have a getLocale() method on Page objects beats me, but here's how you work around it

Using a Redis Server
Jun 16, 2023
By mlocati.

How to configure Concrete to use one or more Redis servers to persist the cache.

Using the Concrete Migration Tool Addon
Apr 27, 2023

How to use the Concrete CMS Migration Tool

How To Add Page Last Updated To Your Concrete CMS Pages
Mar 7, 2023

Concrete CMS has a page attribute you can add to a global area called "Page Date Modified." Here's how to add it

How To Exclude Subpages from Navigation
Dec 24, 2022

How to exclude subpages from navigation - useful for a news or blog link in your main navigation where you don't want all the subpages to appear in a drop down menu.

Improvements?

Let us know by posting here.