8

I understand that Octopress is designed to run as a standalone web application.

I have a personal website, and I want to add a blog to it, and for numerous reasons I would like to use Octopress for this. Rather than having two separate applications and repos in git, I would like to integrate these apps together.

Is there a reliable way to integrate Octopress into an existing Rails 4.0 application?

Would my best bet be to mount Octopress as a rack application inside the Rails router, or is there a better way?

professormeowingtons
  • 3,355
  • 5
  • 31
  • 48
  • 3
    Octopress generates static files, wouldn't it just be sufficient to put them in the public folder of your Rails app? – Wukerplank Jul 04 '13 at 08:29
  • @Wukerplank Octopress is actually a `sinatra/base` app, so I believe it is possible to `mount OctopressApp, :at => '/blog'` inside a Rails `routes.rb` file. – professormeowingtons Jul 04 '13 at 08:39
  • Nope, when you go to your Octopress folder and run `rake generate` you will get a `public` folder containing your blog. Octopress is a wrapper for Jekyll (http://jekyllrb.com) which itself is a static site generator. The Sinatra part you are referring to is for preview and development. – Wukerplank Jul 05 '13 at 07:57
  • Also very interested at this, Currently looking for a way to cleanly integrate octopress inside my rails application, also Rails 4. You found a solution already? – Rubytastic Oct 03 '13 at 08:16
  • @Rubytastic I have not found a good Gemified solution yet -- I may take a more "SOA" route, and have separate components for my blog and my main WWW site. I am also considering rolling my own blog since my requirements are fairly minimal. Let me know what you find by posting an answer here :] – professormeowingtons Oct 03 '13 at 19:59
  • I went for nanoc in the end with some digging the internet this seems the most clean solution. add nanoc to /myapp/blog output its contents to /myapp/public/blog then use nginx config to host the static generated files in public/blog works aswome much cleaner then octopuses but needs more work to get a blog – Rubytastic Oct 03 '13 at 21:25
  • 2
    I think is easier develop your own blog than integrate in rails if you don't need all the features of octopress, but you can create a gem or plugin in order to move your static content, config files and the router engine, but I thing is more complex, in a custom rails app you can integrate a WSGY editor and use Markdown(red carpet) and Luquid or Jekyll – rderoldan1 Oct 16 '13 at 14:25

1 Answers1

1

I think your best bet is to have a frontend server like nginx as a reverse proxy and do the redirecting/proxying from there.

So you will have an nginx.conf something along the lines of:

server {
  listen 80;
  server_name domain.com;
  location / {
    # ... proxy config stuff to rails ...
  }
}

server {
  listen 80;
  server_name blog.mydomain.com;
  location / {
    root /to/octopress/static/folder
  }
}

My example is if you use a subdomain blog.domain.com. But obviously if you have domain.com/blog, it will still work, just do some tweaking on the nging.conf file.

westoque
  • 381
  • 2
  • 10