How do I make ghost home page on a subdir?

Viewed 85

I am attempting to run ghost with the Ghost home page, normally displayed at /, instead displayed on the /blog subdir of my site.

I have followed the Ghost routing docs and the Ghost forum post come up with the following routes.yaml:

routes:

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

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

After starting ghost and visiting http://localhost:2368/blog (or http://localhost:2368/blog/), the page shows:

404

Page not found

Go to the front page →

The 'Go to the front page →' is a link to the same page - /blog.

And in my logs:

[2021-01-26 17:54:58] INFO "GET /blog/" 404 88ms

How do I make ghost home page on a subdir?

1 Answers

I was able to solve this by:

  • Making config.development.json and config.production.json include /blog in the url setting. Eg: "url": "http://localhost:2368/blog",

  • Using the default routes.yaml file is as below - since url is /blog, everything in routes.yaml will be relative to that:

# EVERYTHING HERE IS RELATIVE TO '/blog' - see `url` in config.(environment).json

routes:

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

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