RidingTheClutch.com

Build and publish your Jekyll site with one command

As I’ve mentioned recently, my blog is built with Jekyll. I put together a little script (actually just an alias since I didn’t need any logic) that builds the site and pushes it to my server. My directory structure looks like this:

["\n/rtc\n  /jekyll\n  /raw\n  /site\n"]

/jekyll is the Jekyll source, /raw contains my posts and source files for the site, /site contains the generated code that Jekyll produces.

My alias is called “rtc” and I can just type that at a prompt to build the site and rsync it with my server. Add this to your home directory’s .bash_login or .bash_profile (if you’re on a Mac, the name may be different on Linux but it’s the file that will run each time you bring up the terminal and add all of your custom paths, aliases, etc.). This should all be on one line:

["\nalias rtc=\"echo 'Building...' && ~/Sites/rtc/jekyll/bin/jekyll \n--pygments ~/Sites/rtc/raw ~/Sites/rtc/site && \necho 'Pushing...' && rsync -avz --delete ~/Sites/rtc/site/ \nuser@myserver.com:/var/www/rtc/\"\n"]

You’ll need to replace the directories and user@myserver.com of course. If you have your public ssh key on your remote server then you won’t need to provide a password each time you run this command.

When I run it here’s what I see at the terminal:

["\nBuilding...\nSuccessfully generated site in /Users/rob/Sites/rtc/site\nPushing...\nsending incremental file list\natom.xml\nindex.html\nrobots.txt\n... big long list of files ...\n\nsent 5344 bytes  received 24392 bytes  19824.00 bytes/sec\ntotal size is 5268345  speedup is 177.17\n"]

Done!

blog comments powered by Disqus