by Ryan Walker

Building a website with Nesta CMS

Preparation

  • I created a Disqus account and setup a site, noting the sites “short name”
  • I grabbed my Akismet key that I could optionally give to Disqus (why not)
  • I added a new site profile for Google Analytics and noted the code. Nesta has the tags for Google Analytics baked in, you just have to provide the GA code in config.yml.

Customization

Following the instructions on the github page was easy. I already have basic knowledge of HAML and Markdown, and have used SASS now on several projects.

I iteratively tweaked the SASS into what you see at the website now, chose some starting tags for /content/menu.txt and created blank files in /content/pages for each tag.

I got this somewhat obscure error:

NoMethodError at / private method `split' called for nil:NilClass
  * file: models.rb
  * location: paragraph_is_metadata
  * line: 97

I quickly determined that each of the category pages had to have a header in the file for the site to build, like this:

# Expanded category name

After making some tweaks to the HAML + SASS, I wrote the intro text for the the initial tags I chose. Then I got the first article 1/2 written (the article you’re reading now up to this point) I was on to figure out how to deploy.

Deployment

I read this guide which assumes that I didn’t hack the views directory. So my approach will be to fork the Nesta project + stick my /views changes there, and it’ll also give me a place where I can change core Nesta functionality if I want to.

I head to github.com/gma/nesta, hit the fork button, and now I have github.com/ryw/nesta.

I then edit .git/config and replace:

git://github.com/gma/nesta.git

with:

git@github.com:ryw/nesta.git

Then it’s a simple git commit and my remote repository is now styled the way I want to, and I can continue on with the guide.

cd /content
git init
git add .
git commit -m 'initial content'

connav1 #my alias to ssh to my server
cd apps
mkdir rywalker/content.git
cd rywalker/content.git
git --bare init

Then back on local:

cd path-to-your-content-repo
git remote add server ssh://deploy@av1.anotherventure.com/home/deploy/apps/rywalker/content.git
git config push.default matching

Then back on the server, I clone my nesta source:

cd ~/apps/rywalker
git clone git://github.com/ryw/nesta.git
mkdir nesta/shared nesta/shared/content nesta/current nesta/current/public

Then I added a hooks/post-recieve file to the remote repository (I customized it to keep the nesta code closer to the content and avoid sudo issues, and add -fx to xargs call in last line to avoid rm: missing operand error):

#!/bin/sh
NESTA="/home/deploy/apps/rywalker/nesta"
SHARED="$NESTA/shared"
rm -rf "$SHARED/content.old" "$SHARED/content.new"
git archive --format=tar --prefix=content.new/ HEAD | \
    (cd $SHARED && tar xf -)
mv "$SHARED/content" "$SHARED/content.old"
mv "$SHARED/content.new" "$SHARED/content"
find "$NESTA/public" -name \*.html -or -name \*.xml | xargs rm -f

And made it executable:

chmod +x post-receive

Then I had to install gems on server:

sudo gem install sinatra builder maraku

And get Apache setup:

<VirtualHost *:80>
  ServerName rywalker.com
  ServerAlias www.rywalker.com
  DocumentRoot /home/deploy/apps/rywalker/nesta/public
</VirtualHost>

Reload Apache:

/etc/init.d/apache2 reload

To deploy, all I have to do is push:

git push server

And the site is live & updated. Very cool.