Heroku 上的 Jekyll 博客

发布于 2024-12-06 05:20:48 字数 756 浏览 4 评论 0原文

我正在尝试在 heroku 上建立一个 jekyll 博客。这是我的目录结构,

.
├── Gemfile
├── Gemfile.lock
├── _layouts
│   └── default.html
├── _posts
├── _site
│   ├── Gemfile
│   ├── Gemfile.lock
│   ├── config.ru
│   └── index.html
├── config.ru
└── index.html

我的 Gemfile 拥有

source "http://rubygems.org"
gem 'jekyll'

,只有其中包含任何内容的其他文件是 index.html

Hello world!

如果我运行 jekyll --server 它在本地运行良好。但是如果我git push heroku master(检查完所有内容后)我的heroku日志中会出现此错误

!! Unexpected error while processing request: undefined method `[]' for nil:NilClass

如何让我的jekyll博客在Heroku上工作?

I'm trying to setup a jekyll blog on heroku. This is my dir structure

.
├── Gemfile
├── Gemfile.lock
├── _layouts
│   └── default.html
├── _posts
├── _site
│   ├── Gemfile
│   ├── Gemfile.lock
│   ├── config.ru
│   └── index.html
├── config.ru
└── index.html

My Gemfile has

source "http://rubygems.org"
gem 'jekyll'

and only other file with anything in it is index.html with

Hello world!

If I run jekyll --server it runs fine locally. But if I git push heroku master (after checking everything in) I get this error in my heroku logs

!! Unexpected error while processing request: undefined method `[]' for nil:NilClass

How can I get my jekyll blog to work on Heroku?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉酒的小男人 2024-12-13 05:20:48

我同意phsr的回答。使用亚马逊 CDN 或类似的东西可能会更好地为静态网站提供服务。不过要回答你的问题:

I agree with phsr's answer. Static websites might be better served using amazon CDN or something similar. However to answer your question:

  • Check your static files into your git repo. E.g. into a directory like "public".
  • Set up a config.ru file to use a middleware like rack-static-if-present and point it towards the public directory.
晨光如昨 2024-12-13 05:20:48

Jekyll generates static HTML files, so there is no need to use Heroku. It would be a better idea to host it on S3. See this Amazon blog post on hosting a static site on S3. With the AWS Free tier, your site would be completely free for the first year (as long as it's under 5 GB in size), and would cost pennies a month after that

不必你懂 2024-12-13 05:20:48

我在 Heroku 上运行 jekyll 博客时遇到了很多问题,但最终还是成功了。

如果这仍然相关,您可以在 github 上查看完整代码: https://github.com/ramijames/Blueverve_public

您可以克隆并推送到 Heroku 应用程序,并在那里进行实际设置。

I had a lot of problems getting a jekyll blog running on Heroku, but managed it in the end.

If this is still relevant, you can see the full code here on github: https://github.com/ramijames/Blueverve_public

You can clone and push to a heroku app and fiddle with the actual setup there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文