/ tech-note

How to add a custom route to your Ghost blog?

First, create a custom route directory to your root. Originally I added my custom route files under core/server/, but since it is going to be overwritten by updates on Ghost, it might be preferrable to make them agnostic about the core directory altogether.

Then, define your own custom routes in whatever way you want. Add routes, controllers, or middlewares, etc...

Finally, edit core/server/middleware/index.js and just after the line blogApp.use('/ghost', adminApp);, import your own custom route files and add the routes there.

Example:

var customRoutes = require("../../../customRoutes/index.js");
customRoutes(blogApp);

And it should be done. Test it out in your own blog.