Can a Rails app and a Jekyll blog live together?

... just need to figure out if it's possible to use http://my.app.com/blog as a url (knowing that Jekyll will run its own server process with its own url).

While jekyll's web server works, it will be probably easier, simpler and safer to use your rails app's webserver for serving all pages.

The simplest way of doing what you want is hooking a jekyll invocation to your server's git repository, so jekyll's static content is added automatically to your rails app's public/blog/ directory every time there is a push.

  1. Create a symbolink link called public/blog inside your app's public folder. Make it point to the generated _site folder of your jekyll repository.
  2. On the git repository that controls the contents of the jekyll blog, add a post-receive hook that does the following:

    #!/bin/sh
    
    rm -rf _site
    
    jekyll
    

Those are the basic steps. You might have to configure the read permissions properly, ignore the /blog/ link if you are using an SCM (like you should) and automate the link creation if you are using Capistrano or Vlad for deploying.

There are other alternatives, like using a real folder instead of a symbolic link and having jekyll generate stuff directly there, but I feel the one I'm presenting is the cleanest.


Would you be using nginx to reverse-proxy the Rails app? If so, you should be able to just carve out an exception so /blog is served directly by nginx instead of forwarded to Rails.