Combine Octopress and a Rails 4.0 Application?
Asked Answered
C

1

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?

Cheremkhovo answered 4/7, 2013 at 8:27 Comment(7)
Octopress generates static files, wouldn't it just be sufficient to put them in the public folder of your Rails app?Eyelash
@Eyelash Octopress is actually a sinatra/base app, so I believe it is possible to mount OctopressApp, :at => '/blog' inside a Rails routes.rb file.Cheremkhovo
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 (jekyllrb.com) which itself is a static site generator. The Sinatra part you are referring to is for preview and development.Eyelash
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?Remit
@Remit 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 :]Cheremkhovo
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 blogRemit
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 JekyllCurtal
A
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.

Agueda answered 20/11, 2013 at 5:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.