404 Error on Every Page in Ghost? Here's How to Fix It
Tags: selfhosting, ghost
Published: 2023-05-02 17:34:33

---
title: 404 Error on Every Page in Ghost? Here's How to Fix It
published: true
date: 2023-05-02 17:32:04 UTC
tags: selfhosting,ghost
canonical_url: https://www.mellen.io/ghost-blog-404-error-fix/
---

 ![404 Error on Every Page in Ghost? Here's How to Fix It](https://images.unsplash.com/photo-1541199249251-f713e6145474?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDd8fGFuZ3J5JTIwY29tcHV0ZXJ8ZW58MHx8fHwxNjgzMDQ4NDYx&ixlib=rb-4.0.3&q=80&w=2000)

**TL;DR - Check your `routes.yaml` file. If you've migrated from Ghost (pro) to self-hosted, you are missing vital configuration that isn't provided by Pro.**

A few weeks ago, I migrated my blog from Ghost (pro) to Ghost (self-hosted). The migration _mostly_ went smoothly, with blog posts moving over smoothly and even managing to get Mailgun set up after _quite a few troubles_. One that I only just fixed (oops) was that _every page was 404'ing_.

![404 Error on Every Page in Ghost? Here's How to Fix It](https://www.mellen.io/content/images/2023/05/image.png)
_Don't you just love seeing this?!_

## The Error

The error was simple: _everything_ was giving a 404 error in the frontend. The admin panel worked just fine, and I was able to create posts, pages, and manage my site - it just would not load the frontend. Checking the logs was completely inconclusive, Ghost would simply report a 404 error.

On a _positive_ note, however, Ghost _was_ serving correct redirects. Unfortunately, those redirects lead to 404 pages themselves.

## The Solution

The solution was actually quite simple in the end, albeit not obvious from first glance. I eventually stumbled upon a similar forum thread from January 2022 that said:

> When reviewing your site, it looks like you’re running a custom routes.yaml file, which doesn’t include the base configuration – e.g. the setup that gives tag archive pages their path on the site. The easiest fix for this would be to login to Ghost Admin, and upload the base configuration back to the site, in the Settings > Labs area (under “Routes”).

![404 Error on Every Page in Ghost? Here's How to Fix It](https://www.mellen.io/content/images/2023/05/image-1.png)
_How to get to your Labs area_

And, yep, that was it! My `routes.yaml` file, when copied over from Ghost Pro, was missing vital configuration that would otherwise normally be present. More specifically, I missed this segment:

```
routes:

collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/
```

In my case, I had set up redirects from my old blog articles to their new permalinks within Ghost. So, my config looked a bit like this:

```
301:
  /posts: /
  /posts/2019/i-built-a-serverless-blog-in-30-minutes: /i-built-a-serverless-blog-in-30-minutes
  /posts/2019/i-wrote-the-best-php-obfuscator-as-a-joke: /i-wrote-the-best-php-obfuscator-as-a-joke
  /tags/devops: /tag/devops
  /tags/php: /tag/php
  /tags/programming: /tag/programming
```

This was _perfectly acceptable_ within Ghost Pro, and pretty much every blog post on the planet will echo that. However, Self-Hosted seems to require the additional block above to work properly.

Ghost is a great platform, but unfortunately a _lot_ of its documentation relies on the fact you're running Ghost Pro. On the other hand, for small blogs (hi!) Self-Hosted is a far better option - _especially_ if you already have server space available.

Hope this helps someone out with their self hosting journey!