Getting started with Node.js on Digital Ocean

I have evaluated and used multiple hosting options, PaaS like openshift, Heroku and Iaas like Digital Ocean, Linode and Amazon EC2 and finally have zeroed on Digital Ocean for their simplicity, cost effectiveness and most importantly availability of rich documentations and tutorials.

Pros and Cons of PaaS IaaS has been discussed in many places so we will not go into that discussion here. This is quick refence guide for getting started with Node.js on Digital Ocean.

Digital Ocean has rich set of tutorials for getting stated with different stacks (LAMP, MEAN, crude Node.js etc). Here are set of tutorials which you can follow to get started with Node.js.

  • Get started with Initial Server Set up with Ubuntu 16.04 LTS. These steps are self explainatory and does not need any further clarification.

    • Step One — Root Login
    • Step Two — Create a New User
    • Step Three — Root Privileges
    • Step Four — Add Public Key Authentication
    • Step Five — Disable Password Authentication
    • Step Six — Test Log In
    • Step Seven — Set Up a Basic Firewall
  • Install Node.js. This step will install latest Node.js. Some times you might need some specific version of Node.js. For example, Ghost blogging platform wont run of latest Node.js version as its not yet supported. Ghost official website recommendeds >=4.2 <5.* (Node v4 argon LTS). Please check this tutorial if you want to install specific version of Node.js.

  • Now basic server set up is done and Node.js is installed, now you need nginx server. Follow how to install nginx tutorial to install ngnix.

  • Now you are all set. Follow how to set up Node.js tutorial to set up very basic Node.js application. Once you have done with this step, to get more comfortable with Node.js on ubuntu server, follow creating you first Node.js tutorial . This will give you more hands on and will increase your comfort level.

  • Setting up domain on Digital Ocea is super simple. Simple follow this tutorial to get it done.

    I faced an issue with domains. My website was working perfectly wine with but it was not working for If you also face this issue, please go to Droplets->Add Domain–>Manage Domains and add a ‘A’ record as ‘www’ (without quotes), select your droplet and click on create record. This will resolve your issue.

  • (optional) You can make your website secure by following this tutorial.

  • (optional) If you are getting started and would like to host multiple Node.js websites on the single droplet, follow how to set up multiple virtual blocks tutorial.

Adding Syntax Highlighter to Ghost Blog

Using newer things has its own set of disadvantages and ghost blogging platform is no exception. Ghost does not have efficient coding markup tools. They do have coding style which looks like below:

code Inline Code Ctrl/⌘ + Shift + K

Disadvantage of this way to syntax highlighter is that

  • It does not differentiate between syntax of different lanaguges.

  • formatting is very basis. When I was searching for better ways of doing syntax highlighting, I came across a faq on ghost blog which suggested to use prism.js for syntax highlighting.

This is one of the simplest tool that I have came across and you can set it up in few minutes.

Download prism.js and prism.css from downaload page..
Before downloading these files, you need to select theme and list of languages to which you need this markup.

I have selected Okaidia theme and all languages (you never know which language you might need to refer, specially for a tech blog)

Copy prism.js and prism.css files in following folder respectively


Now we need to include prism.js and prism.css in default.hbs file of whichever theme you are using.
Include prims.css file in head section, just below other CSS files

<link rel="stylesheet" type="text/css" href="{{asset "css/prism.css"}}" />  

Include prism.js file in footer section just before end of body section.

<script type="text/javascript" src="{{asset "js/prism.js"}}"></script>  

This tool has some limitations, as you can see, above line is not rendered properly as html. This is because of double double-quotes. This works well if we remove double-quotes.

<script type="text/javascript" src="{{asset 'js/prism.js'}}"></script>  

Deploy these updated files on your ghost server and you are all set. Language markup can be done as below:

  • language-javascript
  • language-sql
  • language-css
  • language-bash
  • language-html

Installing Node.js and NPM on Ubuntu 16.04 LTS

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

In this article we will look at how to install nodejs and npm on ubuntu 16.04 LTS.

Following commands can be used to check if nodejs and npm is installed on your machin. If its already installed,you will get the installed versions.

$ npm -v
$ node -v

If Node.js is not installed, we can install it by using Node.js PPA provided by official site. As a prerequisite, we need to install python-software-properties package if not installed already.

$ sudo apt-get install python-software-properties
$ curl -sL | sudo -E bash -

Above command will install Node.js versoon 7.X. if you need any previous version, lets say Node v4.8.0 (LTS), please use following command.

$ curl -sL | sudo -E bash -

After adding PPA files, your required Node.js version can be installed using following command.

$ sudo apt-get install nodejs

Once installation is completed, versions can be checked using following commands

$ npm -v
$ node -v

These commands will let you know the latest versions.

Once Node.js has been installed, please check article, creating your first Node.js application to get started

Creating Your First Node.js Application

Follow these instructions to create your fist nodejs application is less than 5 mins.

I assumed you already have nodejs and npm installed on your machine, if not please follow “How to install nodejs” tutorial and come back here after installation is completed.

Open command promt in admin mode and go to the folder where you want to create your first nodejs project. Install express and express-generator using following commands.

npm install express –save  
npm install express-generator –save`  

There are multiple templating option that you can choose such as handlebars, pug, hogan but I choose ejs as its very user friendly and it does not have steep learning curve. Create your first nodejs app by using following command

express --view=ejs myapp  

cd into new folder and install node packages by using following commands

cd . && npm install  

And you are all set. Start your nodejs application by using following command. This will start your application in debug mode.

SET DEBUG=myapp:* & npm start  

If you don’t want to start application in debug mode you can just simple start Node.js app using following command

npm start  

This will get you started with nodejs under 5 minutes. This will create your bare minimum nodejs application. now you can go ahead and do any further front end development that you need.

Our nodejs application is just like steel frame, it just send you one simple webpage, nothing else, we can enhance it further to create data feed api and other complex features. We will look at step by step guide of these at later stages.

How to add Google Analytics to Ghost Blog

Google Analytics is one of the most popular and powerful tool, following article explains how to use add Google Analytics to Ghost Blog. There are two methods to do so.

Adding Google Analytics using Code injection

Follow these steps and you are all set.
1. Add your website to and get the unique code.
2. Login to Ghost Admin section and go to Settings –> Code Injection

3.Insert your code in this section and click “Save” and you are done.

Adding Google Analytics to Ghost theme

  1. Add your website to and get the unique code.
  2. Go to ..contentthemes
  3. Find default.hbs file and open it in your favorite a text editor. I use brackets.
  4. Add it just below the {{ghost_head}} and above .

    5.Restart the ghost and you are all set.

How to install Ghost blog for free on Heroku

Ghost is a fully open source, hackable platform for building and running a modern online publication. It is a very good alternative to WordPress and blogger and Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. Heroku offers a free plan for experiencing the cloud. You can install Ghost on Heroku for free. Following is the step by step guide for installing Ghost Blog on Heroku.

  1. Download Ghost blog from here:
  2. Unzip it into required folder.
    Unzipped folder name is “ghost-0.11.3”. You can keep the name same or change it to any other name. I have renamed folder to “mytravels” as this is my blog name.
  3. Initial NPM and Install required NPM modules
F:mytravels>npm init  

Please follow the instructions as it appears on the screen.

F:mytravels>npm install  

This will take some time as it will install all dependencies.
4 . Initiate git repository

F:mytravels>git init  
Initialized empty Git repository in F:/mytravels/.git/  
  1. Login to Heroku by entering your Heroku credentials
F:mytravels>heroku login  
Password (typing will be hidden):Logged in as  
  1. Create Heroku application
F:mytravels>heroku create  
Creating app... done, desolate-journey-89792 |  

cross check git configuration using following comments

F:mytravels>git remote -v  
heroku (fetch)  
heroku (push)  
  1. Add PostgreSQL database
F:mytravels>heroku addons:add heroku-postgresql:hobby-dev  
Creating heroku-postgresql:hobby-dev on desolate-journey-89792... free  
Database has been created and is available  
 ! This database is empty. If upgrading, you can transfer
 ! data from another database with pg:copy
Created postgresql-slippery-42334 as DATABASE_URL  
Use heroku addons:docs heroku-postgresql to view documentation  
  1. Get database configuration as below:
F:mytravels>heroku config  
=== desolate-journey-89792 Config Vars
DATABASE_URL: postgres://  

These details appear in following order:

  1. Rename config.example.js to config.js and add following code
        production: {
        url: '',
        mail: {},
        database: {
            client: 'postgres',
            connection: {
                host: 'POSTGRES_HOST',
                user: 'POSTGRES_USER',
                password: 'POSTGRES_PASS',
                database: 'POSTGRES_DB',
                port: '5432'
            debug: false
        server: {
            host: '',
            port: process.env.PORT
  1. Add your domain name using following command
  1. Deploy these local changes to Heroku.
git add .  
git commit -am "first commit"  
git push heroku master  

Keyword Research

Whether one is trying to find out niche website, new trends in domain or looking for a new subject for blogs next article, keyword research is the starting point. Developing a list of keywords is one of the first and most important steps in any search engine optimization initiative. Keyword research is a critical component for search engine optimization because when used correctly it provides a road map for both the design and execution of building websites and developing content.

Your keywords in web content makes it possible for people to find website via search engines. A website that is well optimized for search engines “speaks the same language” as its potential visitor base and search engine. In other words, one need to know how people are looking for the products, services or information that website offer, in order to make it easy for them to find you—otherwise, they’ll land on one of the many other pages in the Google results. Implementing keyword SEO will help website rank above competitors.

Following article will discussion scientific method and step by step activities to be done for keyword research. It will also list useful and free tools and websites for keyword research.

What is keyword Research?

“Keyword research is a practice used by search engine optimization professionals to find and research actual search terms people enter into the search engines when conducting a search.”
A keyword is generally a word or phrase that is a topic of significance. Searchers use keywords as a way to identify and verbalize their problem or topic in which they’re looking for more information
Benjamin Brandall from calls it a game, the front page of Google is the leaderboard, with each ranked page being one of the top 10 scores.

Competitor Analysis
  1. Using competing website using
Find Keywords
  1. keyword search box using
  9. Using to find related keywords
  10. Using social media websites (Facebook and writer) to find what people are searching
Keyword Trend
  1. Using google trends to identify search volume over period of time

Keyword research should be an ongoing and ever-evolving part maintaining a website. Old keywords need to be reevaluated periodically, and high-volume, competitive keywords (or “head” keywords, as opposed to long-tailed keywords) can often be usefully replaced or augmented with longer, more specific phrases designed not to bring in just any visitor but exactly the right visitors.

Reference articles

Git Quick Reference

Git is the most useful tool for developers but if someone does not use it for a while, it all seems confusing. Git is tricky. Here are some of the most commonly used command.

  • Copy remote repository to your local folder.
git clone ssh://  
  • Create new git repositiory
git init
  • To get list of files changed in directory
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: MySQL/

Untracked files:
(use "git add <file>..." to include in what will be committed)

MS Excels/

no changes added to commit (use "git add" and/or "git commit -a")
  • View remote repository name
$ git remote -v
origin (fetch)
origin (push)
  • Once you have made your changes and ready for deployment, you following set of commands for deployment.
git add .  
git commit -m "commit comment"  
git push origin master  

For heroku application use following

git push heroku master  
  • What is the difference between git push origin and git push origin master

Following command only pushes your master branch to origin

git push origin master

Following command pushes all your branches to origin

git push origin
  • Get commit history
$git log


How to Deploy Ghost blog on Heroku

Please find below simple steps to deploy your ghost blog on Heroku for free.

  • Download zip file from Ghost blog
  • Unzip it in local folder
  • Go to the unzipped folder using command line and run following commands:
npm init  
npm install  

This will install all dependent modules. Once its done intiate a local Git repository using following command

git init  
  • Now is the time to create your heroku application using following command
heroku create`  
  • Cross check if application is created by using following command
git remote -v  
  • Add postgresql database using following command
heroku addons:add heroku-postgresql:hobby-dev`  

You can get the details of the database using following command

heroku config  

Database is creating using following convention.

  • Now you are all set, just push these changes to Heroku cloud by using following commands.
git add .  
git commit -am "make it better"  
git push heroku master  
  • Go to your heroku account and your Ghost blog is ready for usage.

Additional steps:
If you have a domain name which you want to use for your blog, Heroku allows you to use it even for free account. Use following command to add domain.

heroku domains:add  

Cross check if domain name is added correctly using following command:

heroku domains