Skip to content

Navigation Menu

Sign in
Sign up

Using Ghost as an NPM module

ErisDS edited this page Sep 25, 2014 · 8 revisions

You can now use Ghost as a NPM module!

BREAKING CHANGE

The API for using Ghost as an NPM module is changing in 0.5.2.

Calling ghost() will no longer start an express server. If you have setup Ghost this way with Ghost <0.5.2 you will need to change the code that calls the module. The new API signature will be:

var ghost = require('ghost');
ghost().then(function (ghostServer) {
 ghostServer.start();
});

This documentation will be updated with more details closer to the release.

Using Ghost as an NPM module

  1. Include Ghost as a dependency in your package.json file
"dependencies": {
 "ghost": "0.5.2"
}
  1. Run npm install to install Ghost.

  2. Include the Ghost module where desired and then invoke it to get a promise for a ghostServer object.

var ghost = require('ghost');
ghost().then(function (ghostServer) {
 ghostServer.start();
});

At this point Ghost should be running!

Further customizations

Decide where the content/ directory should exist

By default Ghost will use the content/ directory that exists inside the module. To modify where Ghost's content/ directory should exist you can pass in a JSON object into the ghost() function. For sake of easy maintenance you can also pass in a JSON file:

ghost({
config: path.join(__dirname, 'config.js')
});

An example config.js is based off the config.example.js.

The configuration property that changes the content/ location is:

paths: {
 contentPath: path.join(__dirname, '/content/'),
}

Modify that to change where the content/ directory should exist.

NOTE: If you change the location of the content/ directory Ghost expects to find the same directory structure that exists in the module. To get started copy the default content directory structure as the basis for your custom content/ location.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /