For a long time I have wanted to use Ghost to power my website, but my fear was that I wouldn't be able to write custom functionality without tinkering with the existing Ghost codebase.

My ideal setup would be to incorporate the Ghost blogging platform into my existing node server. This would give me the flexibility to create my own site structure, build custom services and then simply point a specific route (e.g. /blog/) at the Ghost blog and let it work its magic.

As of v0.5.2, it is possible to import Ghost like any other NPM module, which allows you to create a parent express instance, call .use() to add your own middleware and configuration, and then tell the ghostServer to start Ghost with your new parent app.


var path = require('path');  
var ghost = require('ghost');  
var express = require('express');  
var parentApp = express();

  config: path.join(__dirname, 'config.js')
}).then(function (ghostServer) {
    parentApp.use(ghostServer.config.paths.subdir, ghostServer.rootApp);

// Fake service for retrieving tweets
parentApp.get('/api/tweets', function (req, res) {  
    res.json({ tweets: [{
        tweet: 'Ghost blogging platform is great!',
        author: 'TJ'
    }, {
        tweet: 'So happy with my new Ghost setup!',
        author: 'TJ'

Based on the code above, I now have control over the structured of my web server and can start adding my own routes and configuration the same way I would with any other Express app.

Full instructions here