一般编写都是采用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. beta版本工作百分比

    1.附上github上,beta阶段的整体工作情况 2.beta版本分工情况: 马凛凛 031302620(组长):主要负责任务分配和规划,编码工作主要是系统的“实时编辑”功能,以及服务器的配置和部署 ...

  2. Tomcat 在win7/win8 系统下tomcat-users.xml.new(拒绝访问)解决方法

    tomcat启动报错No UserDatabase component found under key UserDatabase 也可以这样处理 Tomcat 在win7/win8 系统下tomcat ...

  3. str和repr的

    尽管str(),repr()和``运算在特性和功能方面都非常相似,事实上repr()和``做的是完全一样的事情,它们返回的是一个对象的“官方”字符串表示,也就是说绝大多数情况下可以通过求值运算(使用内 ...

  4. linux性能监测与优化

    top命令命令功能top命令可以实时动态地查看系统的整体运行情况,是一个综合了多方信息的监测系统性能和运行信息的实用工具.命令语法top(选项)选项说明-b:以批处理模式操作;-d:屏幕刷新间隔时间. ...

  5. BUAA1389愤怒的DZY(最大值最小化)

    http://acm.buaa.edu.cn/problem/1389/ 愤怒的DZY[问题描述]“愤怒的小鸟”如今已经是家喻户晓的游戏了,机智的WJC最近发明了一个类似的新游戏:“愤怒的DZY”.游 ...

  6. Spring MVC:使用SimpleUrlHandlerMapping的一个简单例子

    实现一个控制器ShirdrnController,如下所示: package org.shirdrn.spring.mvc; import java.util.Date; import javax.s ...

  7. tp框架表单验证

    之前的表单验证都是用js写的,这里也可以使用tp框架的验证.但是两者比较而言还是js验证比较好,因为tp框架验证会运行后台代码,这样运行速度和效率就会下降. 自动验证是ThinkPHP模型层提供的一种 ...

  8. Python socket编程之七:多窗口的应用

    f1.py # -*- coding: utf-8 -*- import socket import struct import sqlalchemy import pandas ########## ...

  9. Java统计数据库表中记录数

    public static int count(String txyl_table) {// 获取用户数量 int i = 0;// Store_Information Connection con ...

  10. Visual Studio Online Integrations-Planning

              原文:http://www.visualstudio.com/zh-cn/explore/vso-integrations-directory-vs