Getting Started with the Nesta CMS App Template

20 February 2012

Welcome to Nesta CMS and the starter template/clean theme by Ryan Daigle. Now that you’ve got the site running let’s look at how to use it.

Customization

Go to the local directory where your site was cloned and open the .env file. Edit the configuration values for your site and third-party services (Google analytics, FeedBurner, Disqus, Twitter, GitHub, LinkedIn etc…). For reference my site’s .env file looks like this:

.env
RACK_ENV=development

NESTA_TITLE="Ryan Daigle"
NESTA_FEED_URL=http://feeds.feedburner.com/RyansScraps

NESTA_AUTHOR__NAME=Ryan Daigle
NESTA_AUTHOR__EMAIL=ryan.daigle@gmail.com
NESTA_AUTHOR__URI=http://ryandaigle.com
NESTA_AUTHOR__TWITTER=rwdaigle
NESTA_AUTHOR__GITHUB=rwdaigle
NESTA_AUTHOR__LINKEDIN=rwdaigle

NESTA_THEME=clean
NESTA_POWERED_BY=true

NESTA_CACHE=false
NESTA_CONTENT=content

NESTA_DISQUS_SHORT_NAME=ryandaiglecom
NESTA_PRODUCTION__GOOGLE_ANALYTICS_CODE=UA-77805-8

GAUGES_SITE_ID=123456789
Though the double quotes around the NESTA_TITLE value are ugly when rendered locally, they are necessary for any value with spaces when transferring the environment to Heroku or using the Heroku CLI.

Updating the site on Heroku with new configuration variables can be accomplished with this command:

$ cat .env | grep -v 'RACK_ENV' | tr '\n' ' ' | xargs heroku config:add 

Deploying

You can eploy to your site on Heroku just as you would any Heroku site with a git push heroku master after committing any changes to the git repository. This includes any new articles or content updates you make.

$ git add .
$ git commit -m "Updates"
$ git push heroku master

Writing articles

Please see Nesta CMS’s instructions for writing articles to add pages and new posts to your site.

Updates

Since your site is a fork of the app template any updates to either the theme or the template itself can be easily merged into your site. The template ships with an update script that does this automatically. Execute the following starting in your site’s local root directory:

$ ./update.sh

All the script does is pull in the latest changes to an upstream branch and rebase against it. It commits any local changes first to minimize conflicts. If you’re comfortable managing this process yourself please feel free to do so as the script is provided for convenience only.

Syntax highlighting

The “clean” theme supports syntax highlighting with Pygments. Here are some examples (view the source of the file to see Markdown syntax)

Ruby

example.rb
def greeting
  'Hello World!'
end

Javascript

lib/example.js
var request = require('request'),
  fs = require('fs'),
  spawn = require('child_process').spawn,
  Hash = require('hashish');;

var version = JSON.parse(fs.readFileSync('package.json','utf8')).version;

Terminal output

$ curl "http://gist.github.com/raw/13212qw" > test.txt

Analytics

While there’s support for Google Analytics built into the site template and theme (configurable by editing the .env file) I would recommend taking a look at Gauges instead. It is a much more clean and concise way to measure your site’s traffic, visitors and general analytics and has native iPhone and Android apps.

Gaug.es screenshot

To update your site to send statistics to Gauges simply set the GAUGES_SITE_ID configuration variable on Heroku.

$ heroku config:add GAUGES_SITE_ID=12345678
Adding config vars and restarting app... done, v72
  GAUGES_SITE_ID => 12345678

Performance

New Relic, available for free on Heroku, is an incredibly useful tool for understanding how your site is operating, what kind of performance it’s getting and where any bottlenecks are.

New Relic screenshot

The app template’s deploy.sh script automatically sets up the New Relic add-on. Open up the New Relic dashboard using the heroku addons:open command.

$ heroku addons:open newrelic

Caching

By default the site will cache pages and assets (images, css, js) for one hour. This improves the performance of the site while still allowing a reasonable level of freshness. If your site is like most blogs, this number can be greatly increased since the content rarely changes. To change your site settings to cache assets for 12 hours run the heroku config:add command setting DEFAULT_TTL to the number of seconds.

$ heroku config:add DEFAULT_TTL=43200
Adding config vars and restarting app... done, v72
  DEFAULT_TTL => 43200

Custom domains

Please see Heroku’s custom domain instructions to setup your own domain pointing to the site.

Troubleshooting

Any issues that come up should be reported against the project in GitHub or by commenting on the original announcement post.