开发者

jekyll blog on heroku

开发者 https://www.devze.com 2023-04-07 01:18 出处:网络
I\'m trying to setup a jekyll blog on heroku. This is my dir structure . ├── Gemfile ├── Gemfile.lock

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.htm开发者_C百科l
├── 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?


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消