Rails应用程序和Jekyll博客可以一起生活吗? [英] Can a Rails app and a Jekyll blog live together?

查看:59
本文介绍了Rails应用程序和Jekyll博客可以一起生活吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails应用,我想添加一个博客功能;我的想法是使用Jekyll,这是一个很棒的博客工具,我只需要弄清楚是否可以使用 http://my.app. com/blog 作为网址(知道Jekyll将使用自己的网址运行自己的服务器进程).

I have a Rails app and I want to add a blog feature; my idea is to use Jekyll which is a great blog tool, I 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).

有人知道实现此目标的方法吗?能够做到这一点真是太好了.最好的问候!

Does anybody know of a way to accomplish this? It'd be great to be able to do so. Best regards!

推荐答案

...仅需要弄清楚是否可以使用 http://my.app.com/blog 作为网址(知道Jekyll将使用自己的网址运行自己的服务器进程).

... 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).

虽然jekyll的网络服务器可以工作,但使用Rails应用程序的网络服务器来服务所有页面可能会更容易,更简单,更安全.

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.

执行所需操作的最简单方法是钩住对服务器git存储库的jekyll调用,因此每次推送时jekyll的静态内容都会自动添加到rails应用程序的public/blog/目录中.

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. 在应用程序的public文件夹中创建一个名为public/blog的symbolink链接.使其指向jekyll存储库中生成的_site文件夹.
  2. 在控制jekyll博客内容的git存储库上,添加 post-receive钩子执行以下操作:

  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

这些是基本步骤.您可能必须正确配置读取权限,如果使用的是SCM,则应忽略/blog/链接(如应使用),如果使用的是Capistrano或Vlad进行部署,则可能会自动创建链接.

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.

还有其他选择,例如使用真实的文件夹而不是符号链接,让jekyll直接在其中生成内容,但是我觉得我要呈现的内容是最干净的.

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.

这篇关于Rails应用程序和Jekyll博客可以一起生活吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆