1. 程式人生 > 實用技巧 >使用Github Pages構造屬於自己的部落格:如何在本地使用jekyll

使用Github Pages構造屬於自己的部落格:如何在本地使用jekyll

Jekyll server本地預覽文章not found

解決方案:

找到檔案C:\Ruby26-x64\lib\ruby\2.6.0\webrick\httpservlet\filehandler.rb,具體安裝目錄根據實際情況確定;

檔案修改如下所示;

diff --git a/filehandler_back.rb b/filehandler.rb
index 601882e..10f51d6 100644
--- a/filehandler_back.rb
+++ b/filehandler.rb
@@ -283,6 +283,7 @@ module WEBrick
         # dirty hack for filesystem encoding; in nature, File.expand_path
         # should not be used for path normalization.  [Bug #3345]
         path = req.path_info.dup.force_encoding(Encoding.find("filesystem"))
+       path.force_encoding("UTF-8")
         if trailing_pathsep?(req.path_info)
           # File.expand_path removes the trailing path separator.
           # Adding a character is a workaround to save it.
@@ -330,6 +331,7 @@ module WEBrick
         path_info.unshift("")  # dummy for checking @root dir
         while base = path_info.first
           break if base == "/"
+         base.force_encoding("UTF-8")
           break unless File.directory?(File.expand_path(res.filename + base))
           shift_path_info(req, res, path_info)
           call_callback(:DirectoryCallback, req, res)

主要是新增兩處UTF-8

使用jekyll server的同學需要這樣:

gem update jekyll # 更新jekyll

gem update github-pages #更新依賴的包

使用bundle exec jekyll server的同學在更新 jekyll 後,需要輸入bundle update來更新依賴的包.

bundle install
bundle update

bundle exec jekyll server 本地檢視
bundle exec jekyll build 提交github