• Home
  • About
    • ATERRO photo

      ATERRO

      Though usually reliable,I may let one or two important things slip through my fingers for no apparent reason.

    • Learn More
    • Email
    • Facebook
    • Github
    • Weibo
  • Posts
    • All Posts
    • All Tags
  • Projects

解决Jekyll无法本地预览中文文件的问题

13 May 2017

Reading time ~1 minute

在使用Jekyll在本地预览自己写的博客无法正常打开,而提交到Github上却可以正常解析。看了一下发现是文件写的博客有什么变化,原来是因为博客的Markdown文件使用了中文文件名,Jekyll无法正常解析出现乱码。

解决方法:修改安装目录文件

\ruby-2.3.3-x64-mingw32\lib\ruby\2.3.0\webrick\httpservlet\filehandler.rb

找到下列两处,添加一句(见注释行)

1.

path = req.path_info.dup.force_encoding(Encoding.find("filesystem"))
path.force_encoding("UTF-8") # 加入编码
if trailing_pathsep?(req.path_info)

2.

break if base == "/"
base.force_encoding("UTF-8") #加入编码
break unless File.directory?(File.expand_path(res.filename + base))

修改完重新jekyll serve即可支持中文文件名。



Jekyll Share Tweet +1