一般编写都是采用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. 使用Git进行代码管理心得

    关于使用Git for Windows来clone和上传项目 首先到Git for Windows的官网下载并安装 在本地用来保存clone文件的文件夹右键,选择Git Bash Here: 在打开的 ...

  2. Java基础-静态代理与动态代理比较

    JAVA的静态代理与动态代理比较 静态代理类: 由程序员创建或由特定工具自动生成源代码,再对其编译.在程序运行前,代理类的.class文件就已经存在了.动态代理类: 在程序运行时,运用反射机制动态创建 ...

  3. uploadfile上传文件时ie浏览器无法弹出窗口

    设置--->安全---->activeX筛选取消选择 更多.net.sqlserver.jquery资料欢迎访问 htttp://www.itservicecn.com    

  4. 【POJ 1094】拓扑排序

    题意 给出n,代表有以A开始的n个字母,给出它们的m个小于关系(A<B).如果前i个关系可以确定n个字母的一个顺序就输出: Sorted sequence determined after i ...

  5. Teradata 语句简单优化

    Teradata 基本查询语言和SQL server 是一致的.有很小的区别. 功能没有SQL 全面,界面没有SQL 好看~ 1. teradata 里面经常会报一种错误: no enough spo ...

  6. php复习

    最近要用php,好久不用感觉手生.抓起<零基础学PHP>一书复习了下,顺带学了smarty模板语言,然后到慕课网看了些php中级视频教程,这里记录下. php最基本的文件上传 不用任何第三 ...

  7. codevs1500 后缀排序

    题目描述 Description 天凯是MIT的新生.Prof. HandsomeG给了他一个长度为n的由小写字母构成的字符串,要求他把该字符串的n个后缀(suffix)从小到大排序. 何谓后缀?假设 ...

  8. jquery------使用jQuery的委托方法

    index.jsp <div id="gallery"> <div class="photo"> <img src="a ...

  9. main(int argc,char *argv[])

    #include<iostream.h> //ECHO.CPP void main(int argc,char *argv[]) { ;i<argc;i++)cout<< ...

  10. 从HashMap透析哈希表

    ##扯数据结构 先看一下哈希表的概念: 哈希表是一种数据结构,它可以提供快速的插入操作和查找操作.第一次接触哈希表,他会让人难以置信,因为它的插入和删除.查找都接近O(1)的时间级别.用哈希表,很多操 ...