在使用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即可支持中文文件名。