jekyll-related-posts icon indicating copy to clipboard operation
jekyll-related-posts copied to clipboard

Enabling gem causes all HTML to be downloaded in the browser

Open ghost opened this issue 7 years ago • 11 comments

After updating the gem to the latest version, a new issue cropped up. When serving up the site with:

$ jekyll serve

the site appears fine in the browser at 127.0.0.1:4000. But if I add the gem to my Gemfile (and do nothing else), HTML pages are downloaded instead of displayed in the browser. Doesn't matter what page I try to bring up, the whole site won't display. If I then remove the gem and run jekyll serve, the site displays correctly.

ghost avatar Oct 31 '16 11:10 ghost

I still have the same issue.

I am using Jekyll 3.3.1.

nhoizey avatar Jan 17 '17 13:01 nhoizey

@dstout @nhoizey @alfanick Any fix or work around for this? TIA!

Seems to connected to jekyll serve because if you just build the site the gem works as expected.

I noticed that with the gem the base url for the site was not being edited correctly when being updated in _site.

joshkissel avatar Feb 23 '17 02:02 joshkissel

@joshkissel I tried this on a 1000+ post site, and the publish time went from ~20 sec. to over 5 min. It doesn't store the results of its calculations, so every publish took that long. I like the concept, but this plugin didn't work for my needs.

ghost avatar Feb 23 '17 15:02 ghost

@dstout how is it related to this issue?

nhoizey avatar Feb 23 '17 17:02 nhoizey

@nhoizey Relevant because the developer is MIA.

ghost avatar Feb 23 '17 17:02 ghost

@dstout well, I really think you should have open another issue for this…

nhoizey avatar Feb 23 '17 17:02 nhoizey

Not a final solution, but I got around this problem by replacing jekyll serve --watch with jekyll build --watch and running a web server from the _site directory.

Steps:

  1. Open a new tab in your terminal and cd to the root directory of your project.
  2. Run jekyll build --watch or jekyll build --watch --drafts if you want to see your drafts.
  3. Open another tab in your terminal and cd to <root-directory>/_site.
  4. Run a Python web server:
  • If you have Python 2.x, run: python -m SimpleHTTPServer 4000
  • If you have Python 3.x, run: python -m http.server 4000
  1. Load http://localhost:4000/ as normal.

Hope that helps someone.

jamesbrewerdev avatar Feb 26 '17 09:02 jamesbrewerdev

Hey, I have the same issue, you can see my code at this branch: https://github.com/dmydlarz/blog/compare/related-posts?expand=1

The Content-Type header is changed to application/octet-stream after applying the plugin.

/cc @alfanick

darekmydlarz avatar Nov 09 '17 10:11 darekmydlarz

I encountered this error and digged in a little bit. It was related to this issue. An easy hack would be to explicitly set separator for io.each to avoid being messed up by change made in Packable required by nmatrix required by jekyll-related-posts

In /usr/lib/ruby/2.3.0/webrick/httputils.rb change the following in load_mime_types: io.each{ |line| to: io.each(sep=$/){ |line|

should work fine.

khliu1238 avatar Nov 22 '17 04:11 khliu1238

@khliu1238 I use rbenv and ruby 2.1.3 on macOS. How can I apply this fix?

EDIT I found it at: ~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/webrick. But I believe there should be a better fix for this ;)

darekmydlarz avatar Nov 30 '17 15:11 darekmydlarz

I personally think Packable shouldn't overwrite io functions and break other gems that include it and use those functions.

khliu1238 avatar Dec 01 '17 02:12 khliu1238