I've been tasked with making the error.php file look exactly like the rest of the client's site. I have attempted to create this using code from the main template's index.php file but get lots of errors.

Without redirecting to another page, is there a simple way of creating a 404 page in YooTheme Pro that looks like the rest of the website?!


1 Answer 1


No, as far as I know you can Yootheme Pro only create one 404 Error Page that fits the whole Page without showing anything else from your site.

What I usually do to have an Error Page with Site Elements (Header, Top Menu and Footer), is to create an Error Article, hidden Menu Item and use my own error.php File. The error.php redirects faulty traffic to that Article/Menu Item.

Steps to create a 404 Error Page in a Web Site with Yootheme Pro that shows your Header, Top Menu and Footer:

  • Create a "Sorry, we can not find that page" Article.
  • Create a Menu Item of type Single Article and choose that Article.
  • Set the Alias to 'error' and hide the Menu Item (under "Link Type", choose "Display in Menu": No).
  • Check if the Error Page is displayed at https://example.com/error (but with a HTTP 200 Success).
  • Create an error.php file that redirects faulty traffic to your Error Page and force a "404 Not Found" Status Code. Put that File in a Yootheme Child Theme Folder: /templates/yootheme_some-child-theme-name/error.php.
  • In Yootheme configure "some-child-theme-name" as Child Theme.
  • Put the following code in your /templates/yootheme_some-child-theme-name/error.php.

defined('_JEXEC') or die;

use Joomla\CMS\Uri\Uri;

if ($this->error->getCode() == '404')
    header("HTTP/1.0 404 Not Found");
    echo file_get_contents(URI::root() . '/error');
  • OK, but if it redirects, does the 404 get reported to Google Analytics?
    – Dan
    Mar 14, 2022 at 13:43
  • Yes. You can test this using the Inspect function in Google Chrome: in the network tab you can look at the HTTP headers and see that it will give a HTTP 404 not found status code. Because of the exit; in the if statement, it will give a 404 status code. Without that exit it will give a 200 success (which you don't want).
    – pe7er
    Mar 15, 2022 at 9:12
  • 1
    I have tested this and it worked on my development site, thank you!
    – Dan
    Mar 15, 2022 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.