Blogging and/or setting up a simple site should be a simple proposition. There are a lot of great frameworks out there that handle the software portion of running such a site. However, you don't just want a stock setup. You have to take into account proper asset caching for performance, slick syntax highlighting, an aesthetically pleasing theme, app instrumentation, feed redirection and production deployment.
I've gone ahead and boiled down all these concerns into just a few steps based on the Nesta CMS framework.
Having wrestled with quite a few blogging engines in the past I had several requirements of a new setup. Firstly it had to support a workflow that lets me write on my local machine using the tools I prefer, namely markdown formatted articles composed with IA Writer or a basic text editor.
Second, it had to support a git-based workflow. My content is going to live in git and there's no reason the publishing platform shouldn't build on top of that as well. This also plays well with Heroku deployments.
Static site generators are all the rage and fulfill the first two requirements. However, I've found them to be rather rigid and obtrusive for the very incremental edit-view-edit workflow I assume when writing. My last requirement was that I could write and immediately refresh my browser to see the fully rendered site running locally. Waiting for the whole site to generate on every minor edit proved to be far too slow for me in the past.
Fortunately, there's a better way.
The list of dynamic file-backed Heroku-friendly blog engines isn't particularly long. I investigated both Toto and Nesta CMS and, after a brief wrestle trying to get Toto's HTTP request headers to play nice with rack-cache, settled on Nesta. Nesta is under active development and is written with Sinatra, the very simple and hackable web framework for Ruby.
These steps assume you have git and ruby available from the command line and have already signed up for a Heroku account. The Heroku Toolbelt can get you up and running if you're missing any components.
Though the Nesta quick-start is solid, as are all their docs, we can skip ahead by using an app template. I've created one on github that's already setup for syntax highlighting with Pygments, the "clean" theme you see running this site and the minimal artefacts needed to quickly deploy and provision a full-featured Heroku app.
Fork the starter template using the "Fork" button on the template GitHub page.
This will fork it to your GitHub account. From there you can clone your fork locally. Find the repository URL for your fork and copy it (your URL will differ from the one shown below).
Clone the app template to your local environment using
git. Use the domain name of your site instead of
$ git clone firstname.lastname@example.org:rwdaigle/nesta-app-template.git mysite.com Cloning into mysite.com... remote: Counting objects: 72, done. remote: Compressing objects: 100% (38/38), done. remote: Total 72 (delta 29), reused 63 (delta 20) Receiving objects: 100% (72/72), 11.69 KiB, done. Resolving deltas: 100% (29/29), done.
The application's source is now installed locally in the
Now that the site template is present in the local environment you can install required dependencies and render the site locally before deploying to a remote server environment. A
bootstrap.sh script is provided for your convenience.
bootstrap.sh script does not use sudo or make any destructive commands. However, please review the script source before executing.
$ cat bootstrap.sh # ... script source $ ./bootstrap.sh Using RedCloth (4.2.9) Using addressable (2.2.7) # ... Submodule path 'themes/clean': checked out '889e094749008d2bf4ecf901555fce44c7f7bc87'
Once bootstrap has finished start the app using the
$ foreman start 14:25:47 web.1 | started with pid 59647
Opening http://localhost:5000 should display the site running with a single getting started article listed on the home page. Any errors that occur will be shown in the terminal where you entered the
foreman start command.
Assuming you have a Heroku account and have successfully installed the Heroku Toolbelt you can use the provided helper script to quickly deploy the site install any dependencies and setup the appropriate configuration.
The app deployed to Heroku will not incur any charges on Heroku.
$ cat deploy.sh # ... review script source ... $ ./deploy.sh Creating vivid-sword-9170... done, stack is cedar Adding memcache to vivid-sword-9170... done # ... Opening http://vivid-sword-9170.herokuapp.com/
You've forked your own copy of the app template, got it running locally and deployed it for free to Heroku. Not bad for a few minutes of your time! To customize the site, setup analytics and write your first post go ahead and read the welcome post included in your new site (a copy can be found here).
My hope is this template and theme eliminates many of the sticking points associated with taking a great framework like Nesta and turning it into a running, usable and deployed site. Let me know if you run into any issues (or better yet, submit a pull request to the template or theme projects on GitHub).