How to set up a jekyll blog near your rails app. ⚗️

How to set up a jekyll blog near your rails app. ⚗️

  • bubblin
  • 4 minutes
  • August 28, 2018

Our prototype was ready to go live and we needed a blog to announce our startup.

Great! But how do you do that? …¯\(ツ)

Easy. Do it yourself. It’s so easy to set up a blog. Don’t miss out on all that “domain authority” and the SEO juices that come along with a subdirectory like this: /

If you’re building a tech startup, it is important to wiggle a little harder and setup your own blog. Your blog is how the search Gods will make sure potential customers or users find you instead of Medium.

The following guide will help you setup a simple Jekyll blog alongside your rails app but the process would essentially be the same no matter which stack (node, python, java or others) you’re on.

This post assumes that you love ruby_on_rails like I do and have an application (startup?) alive at your own You’ve got your app, but now you need a blog at /blog url of to dent the world with your announcement post.

Consider yourself lucky because you’re at the right place at the right time right now, so read on…

Of course, we too made our announcement too using the same technique last week!

We wanted to have a blog for Bubblin Superbooks to announce new features and post updates. We are on rails 5.2 and wanted our blog to reside on the same top_level_domain ( vs. as the main product itself. Why? Because SEO, if you missed it earlier.

There’s a couple of ways to set up a blog and quite a few open-source options (wordpress/ghost etc.) out there, but we decided to use Jekyll with markdown for the sake of simplicity.

Jekyll is rack-based like most rails apps and I really enjoy writing with markdown.

For the uninitiated, Jekyll is a simple blog-aware generator so all we need to do is publish it alongside our rails app online via the public directory. From there, the web-server will take care of the rest. Note the blog doesn’t have to be coupled with the rails app itself, it just has to sit nearby, like a sibling, and work in a way similar to how static uploads do.

Let’s look at the setup first.


Assuming that your startup (or rails app) is going to be called in your terminal:

$ mkdir ~/projects/
$ cd ~/projects/
$ rails new 			// your app may already exist.

Now that we have the rails app (~/project/, let’s go ahead and get our blog ready. As of writing this post jekyll requires you have at least Ruby 2.2.5 installed on your system, but for the latest instructions, check the Jekyll setup guide.

$ cd ~/projects/ 		// or cd .. if you're inside the rails app.
$ gem install bundler jekyll
$ jekyll new
$ cd && bundle install

Go ahead and commit your blog to its own new repo:

$ git init && git add . -A
$ git commit -m "Setting up a jekyll blog on the side…"
$ git remote add origin [email protected]:username/
$ git push -u origin master

Once Jekyll finishes you’ll have the blog at ~/project/ and the rails app at ~/project/, like so:

[email protected] in ~/projects/ $ ls


This is what our jekyll blog looks like:

ls ~/project/
404.html      Gemfile.lock  _posts        bin 
Gemfile       _config.yml   _site

Modify the baseurl option on _config.yml of your jekyll instance to point it to /blog.

baseurl: "/blog" 			// the subpath of your site, e.g. /blog, /docs

This is important so that assets load and link back properly. To ensure everything is working, start the jekyll server and preview the blog on your browser. You can also apply a theme to your blog to match with your site’s layout. We customized our jekyll blog and open sourced our theme in form of a gem along with a guide to help you dip your fingers in quickly:

(Simply fork it, replace logos and links, and you’re all set!)

Since we’re hosting Bubblin on Linode I wanted to make sure that the public/ directory is committed properly. Remove ‘public/’ from the .gitignore file if that is necessary to commit the directory. What we’ll do next is simply adding a shared directory on our deployer recipe to tell rails where the requests to our blog will go. Thereon we can just build and rsync the jekyll site to our blog directory on server. Easy peasy.

We’re using Capistrano for build deployments so I added the “blog/” as a linked_directory on our deployer recipe:

$ cd ~/project/ 		// In your rails/node/python app
➜ $ vi ~/project/

Add public/blog to the following line:

set :linked_dirs, %w{public/blog log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

Exit vim with \wq!.


To publish we’ll use a two line deployer script that builds jekyll and rsyncs it to the public directory of our rails application. If you don’t have rsync installed, you could use scp instead, or you’ll need to install one of these tools with your favorite package manager. Since I’m on mac, I use the Homebrew.

$ cd ~/project/ && mkdir bin 	// Create a `bin` dir here.
$ cd bin && touch deploy 				// Note there is no dotfile extension on this script
$ vi deploy

Add the following lines to it:

#! /bin/sh

jekyll build
rsync -va _site/ ../
# rsync -va _site/ 	// Uncomment for production.

Exit vim with \wq!. It’s a good idea to make it executable as well:

chmod +x ~/project/

At the root of your blog execute $ . bin/deploy, and you’ll see rsync run and put the Jekyll build inside your rails app’s public/ directory.

Now you can work on the app and the blog independently without mixing dependencies.

That’s how you setup a simple jekyll blog near your rails app. Now you can drop that big announcement post. All the best with your startup!

P.S.: Did you know Bubblin is to books, what jekyll is to blogs?

About the author

Sonica Arora

A tree hugger at heart. Code, stories & coffee.