Ghost – Just a Blogging Platform

ghost_header

By Eric Terpstra

Ghost is a new open source blogging platform dedicated solely to dead-simple publishing. It’s goal it to let writers write, and have fun doing it. No crazy hierarchy of menus to wade through; no finicky WYSIWYG editor mangling HTML; nothing to worry about except creating delightful posts. According to the creators of the project, Ghost is and always will be, “Just a Blogging Platform.”

The internet at large seemed to agree with this notion. Last April, a Kickstarter campaign raised nearly £200,000 to fund the development of Ghost. This funding allowed the formation of a non-profit entity to oversee the development of Ghost and manage a hosting platform coming later this year.

The Ghost project is led by John O’Nolan, who came up with the idea and drives the vision, and Hannah Wolfe who leads the development effort and makes the vision reality. Development takes place on GitHub and everything else Ghost related is available at Ghost.org.

Built on NodeJS…

nodejs

One of the most common criticisms of Ghost so far is focused on the choice of technology platform – NodeJS. Many non-technical folks frown at the lack of shared hosting options and cryptic use of the command line. Developers have questioned the use of Node as a platform, stating that a traditional web application such as a CMS is better suited for more mature technologies such as PHP, Rails or Django.

However, the momentum of NodeJS is undeniable. Say what you want about its speed and asyncronicity – the simple fact that one language can be used to create both the client and server provides a huge win for web developers. It is my opinion that JavaScript will become the dominant language for web applications in the years coming (both client and server side), but don’t take my word for it…

“We’re really excited about building [Ghost] in JavaScript, because most of the future of the web seems to be written in JavaScript… It makes sense for us to create a really dynamic, responsive, interactive application on both the front and back end with JavaScript.” – John O’Nolan, The Changelog ep. 105

Aside from the technical merits of JavaScript and the one-language-to-rule-them-all architecture, the community effort surrounding Node and JavaScript is burgeoning.

“…we wanted to position Ghost to be part of this vibrant JavaScript open-source community.” – Hannah Wolfe, LXJS 2013

Starting a new project based entirely in JavaScript relieves the Ghost team of any preconceived notions and opinions inherent in more established platforms, but they also open themselves up to brand new challenges. Hopefully overcoming these challenges will only help drive innovation forward and improve the quality of the JavaScript community.

…And Express

ghost_stack

The foundation of Ghost is built upon Express – a lightweight web application framework for NodeJS. Express provides a basic MVC style structure to the application as well as a pile of utilities in the form of libraries and middleware. Ghost makes heavy use of Express routes to handle requests and organize back-end logic. Other notable Node modules are integrated to help out with the model and view layers.

Another controversial technical decision made by the Ghost core team is the use of SQLite as the default database. In context, though, it makes perfect sense. Using SQLite removes the dependence on a separately installed database server. The installation process for Ghost will download a pre-compiled binary executable of SQLite for most platforms (including Windows). A database instance is set up automatically when Ghost runs for the first time. It’s all very smooth, and Ghost operates like a single cohesive application, rather than a conglomeration of applications and servers you might find with other platforms.

If the thought of running your precious blog with thousands of posts and millions of visitors on a SQLite database makes you cringe, fear not. Ghost is using a new ORM called Bookshelf, along with a query builder called Knex, to abstract away any real dependencies on SQLite itself. In fact, the core team already has Ghost working with MySQL, and community members have reported PostgreSQL working as well. Support for additional databases such as MongoDB are also planned for the future.

The view layer of the application uses Handlebars templates. As of Ghost version 0.3, part of the application is rendered on the server and returned as HTML, and part of the application functions like a single-page app. In some places Backbone.js views render Handlebars templates and make requests to Express routes for new data. It’s a little convoluted, but discussion is underway on refactoring more towards the single-page app / service-oriented architecture.

There are tons of other great libraries in use, including When for promises, and Showdown for Markdown parsing. If you are really interested in the inner workings, take a look at the repo on GitHub for a complete look at the source code. There are also plenty of interesting discussions going on in the Issues around the architecture and potential refactoring in the Top Priority queue. Much of the Ghost team is also available on Freenode (IRC) in #Ghost.

Download and Install

To get your hands on Ghost and start using it on your local machine, you have several options.

ghost_setup

By far the easiest method so far is the BitNami installer. It is a downloadable point-and-click style installation wizard that gets Ghost running in a self contained sandbox environment. No command line interaction is necessary. It is the easiest, but also the least flexible option.

The most common method of downloading and installing Ghost is by visiting ghost.org/download and downloading a pre-built .zip file of the latest stable release. It contains all the source in the repository, but has the SASS and Handlebars templates precompiled for you. You still need to have NodeJS installed on your system beforehand though.

ghost_buildsource

To install with the default settings, simply unzip the file, go to the unzipped subdirectory in your command prompt, and run npm install --production and then npm start. Ghost should start on localhost using port 2368. Take a look at the getting started guide for more info.

For the brave and/or curious, you can also install Ghost by cloning the GitHub repository and building it on your system with the included Grunt tasks. You will need to have Grunt, Sass and Bourbon installed before attempting this, though. The contributing guide has full instructions on installing from source.

Additionally, if you are a fan of virtual machines, the Ghost team also has a pre-built Vagrant profile available for download. I haven’t used it myself, but it’s kept up to date and has detailed setup instructions in the README file.

To keep Ghost running in the background, rather than occupying a terminal session the entire time it’s running, look into the Forever module. It allows multiple NodeJS applications to run in the background, and will automatically restart them if they crash.

Start Blogging

ghost_strt

Once installed, visit http://127.0.0.1/ghost to set up your user account and log into the admin panel. The interface is intuitive enough to immediately start writing – click the + icon to create a new post, go to the Settings menu to change the logo and banner image, etc… A full user guide is available at http://docs.ghost.org/usage/.

ghost_editor

Where Ghost really shines is with its Markdown writing interface. There are a ton of keyboard shortcuts that aren’t immediately apparent, but are tremendously useful. There is a Markdown help panel and keyboard shortcut listing available by clicking the (?) icon just underneath the title. The writing interface allows you to write and format an entire post without taking your hands off the keyboard or typing out verbose HTML tags. You can even add placeholders for images using the keyboard, then drag and drop them into your post when the writing is complete. It’s very slick, and once you get used to it, is much faster than using a WYSIWYG editor.

Create Your Own Themes

If you want to add a little flavor to your blog, creating a custom theme is fairly straightforward. Ghost themes are HTML, CSS and JavaScript site templates that employ Handlebars to fill in the dynamic content such as posts, author info, and blog settings.

Themes are intended to be as logic-less as possible with regards to content. Any manipulations made to the content or display settings should be handled by Ghost itself. In next major release (0.4), a plugin API will be introduced that will allow the creation of custom theme ‘helpers’. Some additional built-in features such as per-post banner images, and a static navigation menu interface are coming as well.

ghost_templates

The easiest way start a new theme is to copy the default theme – Casper. Duplicate the /content/themes/casper subdirectory and give it a new name. Restarting Ghost is necessary to have the new theme appear in the Settings menu. Once the new theme is activated, you are free to manipulate the CSS, JavaScript and Handlebars templates (.hbs files) and the changes should be reflected immediately. A basic theme guide is available at http://docs.ghost.org/themes/, and a more in-depth look at themes can be found at TutsPlus.

There are a few third-party themes listed on the Ghost Marketplace preview, and a few dedicated Ghost theme stores have popped up as well (including my own – Theme Spectre). For a more advanced starter theme, take a look at Linen (available on GitHub) which makes use of additional HBS templates, SASS, and Grunt.

Go Live

Arguably the biggest roadblock to actually using Ghost as a real world blogging platform is finding a place to host it online. Those that are familiar with Node probably won’t have trouble firing it up on a VPS, but for those used to shared hosting and 1-click installers are running into friction. Luckily the popularity of Ghost has already convinced some large hosting companies to take action and create easy(er) options for Ghost hosting.

Rackspace has a predefined deployment, Digital Ocean has a ‘droplet’, BitNami lets you migrate your local installation online, and newcomer hostghost.io just gives you a pre-installed Ghost instance. Hosting yourself on a VPS is a viable option as well, and this can be done at pretty much any VPS provider. Check the ‘deploy’ page of the Ghost documentation for more info.

Ghost itself will have its own paid hosting option later this year. What’s particularly interesting is that because Ghost is a non-profit, all proceeds from the hosting platform are de-facto reinvested into Ghost. There are no owners or investors to appease, so the Ghost team is only accountable to its users.

Conclusion

I may be a bit biased, but I think Ghost is more than “just a blogging platform”. With all the success and popularity it’s garnered thus far, Ghost has the potential to be a ‘killer app’ for Node. Thousands of Ghost’s Kickstarter backers previously had no exposure to NodeJS, and are now (in some cases begrudgingly) accepting it as readily as they would a PHP application. Hosting services who previously had NodeJS service as an afterthought are now bending over backwards to get proper NodeJS and Ghost offerings on the table. Ghost is not the first project to thrust Node into the limelight, but it’s certainly helping it stay on the big stage.

Modern Web Newsletter

Subscribe to receive the Modern Web tutorials, sent out every second Wednesday.

  • http://webdev2.io/ Simon

    I can totally get the idea of using NodeJS for this, but how can they justify the fact it isn’t even compatible with services like https://www.nodejitsu.com/ ?

    Also with regards to this point:- “Many non-technical folks frown at the lack of shared hosting options and cryptic use of the command line.” I have witnessed many technical folk having problems, people who are not afraid of getting stuck into code and already using things like Jekyll. So it’s not just the non-technical that have experienced difficulties.

  • http://michaelmusgrove.com Michael Musgrove

    I’ve been using Ghost and am impressed, considering the timeframe and expectations involved. Remember, we’re only at v 0.3.3. I’ve set up a pile of sites using Digital Ocean and have been having a great ride 99% of the time. In time, I feel positive the tech hurdles and bugs will ironed out and Ghost will be a very formidable contender.

  • http://blazemeter.com Bob

    Ghost is awesome platform, especially there is no performance issues with it. We made performance test Ghost and WordPress to compare them. Ghost handles 1000 concurrent users and WordPress handles less than Ghost.

Top