Deploy
DocPad websites can be deployed anywhere. Here are a few of the most common deployments.
To a Node.js Hosting Provider
Inside your website's directory
Add the following to your website's
package.jsonfile. Add all the dependencies you are using and make sure their versions are correct - as well as ensure all commas are correctly placed."engines" : { "node": "0.10", "npm": "1.2" }, "dependencies": { "docpad": "6.x", "docpad-plugin-blah": "2.x" }, "main": "node_modules/docpad/bin/docpad-server", "scripts": { "start": "node_modules/docpad/bin/docpad-server" }
For deployment to Heroku
Create a
Procfilefile inside your project that contains:web: node_modules/docpad/bin/docpad-serverSet your heroku instance to run in production mode
heroku config:add NODE_ENV=production
For deployment to AppFog
Create a
app.jsfile inside your project that contains:module.exports = require(__dirname+'/node_modules/docpad/out/bin/docpad-server');
For deployment to Windows Azure
Create a deployment script that triggers the static content generation. To create the script run the following command using the Windows Azure CLI Tools:
azure site deploymentscript --basic -t bashModify the
deploy.shfile by chaning the# Deploymentsection to the following lines. You can see a complete example of the deploy.sh file here.echo Handling deployment. # 1. Install npm packages if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then cd "$DEPLOYMENT_SOURCE" npm install --production --silent exitWithMessageOnError "npm failed" cd - > /dev/null fi # 2. Build DocPad Site echo Building the DocPad site cd "$DEPLOYMENT_SOURCE" node ./node_modules/docpad/bin/docpad generate exitWithMessageOnError "Docpad generation failed" # 3. KuduSync echo Kudu Sync from "$DEPLOYMENT_SOURCE/out" to "$DEPLOYMENT_TARGET" $KUDU_SYNC_COMMAND -q -f "$DEPLOYMENT_SOURCE/out" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.deployment;deploy.sh" 2> /dev/null exitWithMessageOnError "Kudu Sync failed"Last, create a web.config file in the files directory of your site with the URL rewrite rules shown below. These rules remove the html extensions from your urls. You can see the main portions of this web.config file below. You can download the complete file here.
<rule name="RemoveHTMLExtensions" stopProcessing="true"> <match url="^(.*)\.html$" /> <action type="Redirect" url="{R:1}" appendQueryString="true" /> </rule> <rule name="RewriteHTMLExtensions" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> </conditions> <action type="Rewrite" url="{R:1}.html" /> </rule>
For deployment to Nodejitsu
For deployment to Modulus
Optional: Custom domains
If you're also wanting to use custom domains for your website, follow the Heroku Guide here, or alternatively here is a generic guide:
Ping your server e.g.
ping balupton.herokuapp.comGrab the IP address from the output
Login to your domain's DNS manager
Create an A Record for your domain pointing to that IP address
To Static Servers (Apache, Nginx, etc)
Perform a generation for a static production environment using
docpad generate --env staticUpload the generated directory to your server's
public_htmlorhtdocsdirectory
To GitHub Pages
Install the GitHub Pages Plugin
npm install --save docpad-plugin-ghpagesDeploy to GitHub Pages using the plugin
docpad deploy-ghpages