404 page template & redirect

Hi,
Maybe is very simple, but I don’t know how to create a template for the error 404 page. Also, is there a way do redirect 404 to home?
Thanks

I’m using this way, but you have many other ways!, in my error.yml i have a structure like that:

title: Error
pages: false
files: false
fields:
  errortitle:
    label: Title
    type:  text
```
and the error.php template
```
<div>
<div class="error-page-container center mb3"> 
<!-- 404 Page -->
<h2><?php echo $page->errortitle()->html() ?></h2>
<div class="big-error-number">404</div>
<a href="<?php echo $site->url() ?>"><button><?php echo $site->homePage()->title() ?></button></a>
</div>
</div>

```

and also in the CSS.

```
/*--------------------------------------------------
404 Page
---------------------------------------------------*/
.error-page-container .big-error-number {
  font-size: 6.5rem;
  line-height: 6.5rem;
  text-align: center;
}

.error-page-container h2 {
  font-size: 1rem;
}

@media (min-width: 40em) {
  .error-page-container .big-error-number {
    font-size: 14.5rem;
    line-height: 14.5rem;
  }

  .error-page-container h2 {
    font-size: 2rem;
  }
}
```

hope it is helpfull for you :blush:
1 Like

To redirect to home instead of error, you can either use a route or place a redirect in the error template:

<?php
go('/');
3 Likes