一般编写都是采用utf-8的吧,但是在windows下安装的jekyll,默认是以GBK编码的方式去读取咱们编写的文件,如此便乱码了。

要解决此问题,总不至于要写GBK编码的文件吧,毕竟这个编码不怎么通用,所以需要修改jekyll中的代码,让其以utf-8编码来读取我们的文件,已有网友找到解决方法!需要修改jekyll中读取的代码,指定为utf-8编码即可。具体如下:

错误信息:

   Generating... Error reading file e:/xampp/htdocs/ieverx/ieverx/_posts/
---logic-operation-in-python.md:
invalid byte sequence in GBK
error: invalid byte sequence in GBK. Use --trace to view backtrace

修改方法:

/文件:C:\Ruby200\lib\ruby\gems\2.0.0\gems\jekyll-1.2.1\lib\jekyll
//具体路径视版本号及安装路径有所不同
//找到如下代码:
self.content = File.read(File.join(base, name))
//修改为:
self.content = File.read(File.join(base, name), :encoding => "utf-8")

之后在文件中写入中文时,记得保存为utf-8的编码,否则运行时会报错的哦!

事后(2013-09-20),在C:\Ruby200\lib\ruby\gems\2.0.0\gems\jekyll-1.2.1\site中发现疑似jekyll官网源码,且是以jekyll来运行的,于是好奇考出执行jekyll serve命令,谁知报如下错误:

初步推测是编码问题,此时前面提到的编码问题已经修复,定是其它地方出现此类问题导致。通过jekyll serve --trace命令打印出详细错误信息:

from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/template.rb:169:in `tokenize'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/template.rb:75:in `parse'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/template.rb:62:in `parse'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/tags/include.rb:59:in `render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/block.rb:137:in `block in render_all'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/block.rb:124:in `each'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/block.rb:124:in `render_all'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/block.rb:110:in `render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/template.rb:150:in `render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/liquid-2.5.2/lib/liquid/template.rb:160:in `render!'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/convertible.rb:82:in `render_liquid'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/convertible.rb:113:in `render_all_layouts'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/convertible.rb:148:in `do_layout'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/post.rb:259:in `render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/site.rb:205:in `block in render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/site.rb:204:in `each'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/site.rb:204:in `render'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/site.rb:36:in `process'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/command.rb:18:in `process_site'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/commands/build.rb:23:in `build'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/lib/jekyll/commands/build.rb:7:in `process'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/jekyll-1.2.1/bin/jekyll:99:in `block (2 levels) in <top (required)>'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/command.rb:180:in `call'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/command.rb:155:in `run'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/runner.rb:402:in `run_active_command'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/runner.rb:78:in `run!'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/delegates.rb:11:in `run!'
from C://Ruby200/lib/ruby/gems/2.0.0/gems/commander-4.1.5/lib/commander/import.rb:10:in `block in <top (required)>'

之后一个个文件查看了下,发现C:\Ruby200\lib\ruby\gems\2.0.0\gems\jekyll-1.2.1\lib\jekyll\tags\include.rb中有有文件读取代码,经如下修改能正常运行:

#原来的代码
source = File.read(File.join(includes_dir, @file)) #修改为以utf-8编码读取
source = File.read(File.join(includes_dir, @file),:encoding=>"utf-8")

编码问题解决之后!
继续

jekyll server

接着出现的问题

      Generating... You are missing a library required for Markdown. Please run:

  $ [sudo] gem install kramdown
Conversion error: There was an error converting '_posts/2012-06-20-logic-opera
tion-in-python.md/#excerpt'. ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
Missing dependency: kramdown

则直接输入

gem install kramdown

全部完成!

jekyll中文乱码问题的更多相关文章

  1. java中文乱码解决之道(一)-----认识字符集

    沉寂了许久(大概有三个多月了吧),LZ"按捺不住"开始写博了! java编码中的中文问题是一个老生常谈的问题了,每次遇到中文乱码LZ要么是按照以前的经验修改,要么则是baidu.c ...

  2. MAC下 mysql不能插入中文和中文乱码的问题总结

    MAC下 mysql不能插入中文和中文乱码的问题总结 前言 本文中所提到的问题解决方案,都是基于mac环境下的,但其他环境,比如windows应该也适用. 问题描述 本文解决下边两个问题: 往mysq ...

  3. java中文乱码解决之道(九)-----总结

    乱码,我们前台展示的杀手,可能有些朋友和我的经历一样:遇到乱码先按照自己的经验来解决,如果没有解决就google,运气好一搜就可以解决,运气不好可能够你折腾一番了.LZ之所以写这个系列博客就是因为遇到 ...

  4. 解决springmvc+mybatis+mysql中文乱码问题【转】

    这篇文章主要介绍了解决java中springmvc+mybatis+mysql中文乱码问题的相关资料,需要的朋友可以参考下 近日使用ajax请求springmvc后台查询mysql数据库,页面显示中文 ...

  5. freemarker页面中文乱码

    一.前言 简单的记录freemarker遇到的错误问题:ftl页面中文乱码 由于freemarker整合在ssm框架中,所以笔者直接贴配置代码 <beans xmlns="http:/ ...

  6. tomcat项目中文乱码问题解决方法

    在部署tomcat项目时经常会遇到中文乱码问题,解决的方法可参考以下步骤. 1.更改Tomcat安装目录下的conf\server.xml,指定浏览器的编码格式为"utf-8"格式 ...

  7. IE下get传中文乱码的问题 -- 解决方案 (js)

    W3school 函数 JavaScript 全局对象 定义和用法 encodeURI() 函数可把字符串作为 URI 进行编码. 语法 encodeURI(URIstring) 参数 描述 URIs ...

  8. JSP和Servlet的中文乱码处理

    JSP和Servlet的中文乱码处理 前几天学习了JSP和Servlet中有关中文乱码的一些问题,写成了博客,今天进行更新一下.应该是可以解决日常的乱码问题了.现在作以下总结希望对需要的人有所帮助.我 ...

  9. Git bash下中文乱码问题

    Git bash下中文乱码--解决方案 解决办法1: 在git bash下,右键 出现下图,选择options: 选择"Text" 将Character set设置为 UTF-8 ...

随机推荐

  1. java通过地址获取主机名

    关键代码: try { String str=Chat.getJt().getText().toString();//获取输入内容 String[] ipstr=str.split("[.] ...

  2. Timer的性能优势

    假如有这样一个场景,1个100万用户同时在线的系统,假设有一个Session管理器来管理它们的存亡,每个用户的Session有效时间假设5分钟,通常一个最简单的做法是在一个Session管理器中启动一 ...

  3. oracle-1

    使用sqlplus 进入oracle (1)服务的启动终止 oracle 服务的关闭: SQL> shutdown immediate; oracle服务的启动: SQL> startup ...

  4. Git 常用命令详解(二)

    Git 是一个很强大的分布式版本管理工具,它不但适用于管理大型开源软件的源代码(如:linux kernel),管理私人的文档和源代码也有很多优势(如:wsi-lgame-pro) Git 的更多介绍 ...

  5. Html-Css-div标签嵌套浮动div标签时无法撑开外部div的解决

    当DIV1里面嵌套有一个DIV2,当DIV2设置了浮动,那么DIV1是无法被撑开的 当DIV1里面嵌套有一个DIV2,当DIV2设置了浮动,那么DIV1是无法被撑开的,也就是说DIV2在这里相当于浮在 ...

  6. opencv笔记6:角点检测

    time:2015年10月09日 星期五 23时11分58秒 # opencv笔记6:角点检测 update:从角点检测,学习图像的特征,这是后续图像跟踪.图像匹配的基础. 角点检测是什么鬼?前面一篇 ...

  7. 内部类访问局部变量的时候,为什么变量必须加上final修饰

    这里的局部变量就是在类方法中的变量,能访问方法中变量的类当然也是局部内部类了.我们都知道,局部变量在所处的函数执行完之后就释放了,但是内部类对象如果还有引用指向的话它是还存在的.例如下面的代码: cl ...

  8. Redis操作+python

    自动化接口测试中需要向redis中插入测试数据: 1. 连接redis: import redisself.r = redis.StrictRedis(host=env.REDIS_HOST, por ...

  9. js正则表达式中的问号几种用法小结

    这篇文章主要介绍了js正则表达式中的问号几种用法,比如+?,*?,{2,3}?可以停止匹配的贪婪模式,感兴趣的朋友可以参考下 在表示重复的字符后面加问号,比如+?,*?,{2,3}?可以停止匹配的贪婪 ...

  10. ASP.NET WebAPI 03 返回结果

    在WebAPI中HttResponseMessage作为消息返回,而在ApiController中我们经常讲四类数据作为返回值,void,object(可序列化),IHttpActionResult, ...