<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>SeanLou的博客</title>
  <link href="http://lxj.name/atom.xml" rel="self"/>
  <link href="http://lxj.name/"/>
  <updated>2012-03-21T19:02:02-07:00</updated>
  <id>http://lxj.name/</id>
  <author>
    <name>SeanLou</name>
    <email>louxiaojian@gmail.com</email>
  </author>
  
    <entry>
      <title>Web开发中初学者容易混淆的9个命名约定</title>
      <link href="http://lxj.name/javascript/2012/03/15/mingming.html"/>
      <updated>2012-03-15T00:00:00-07:00</updated>
      <id>http://lxj.name/javascript/2012/03/15/mingming</id>
      <content type="html">        http://dayanjia.com/2010/10/9-confusing-naming-conventions-for-beginners-in-web-programming.html
  		&lt;p&gt;当人们一开始接触各种Web开发语言时，总会发现彻底搞懂不同语言的命名约定是一件很要命的事情。而且当开发者在争论什么才是最佳实践时，事情会变得更加让人困惑。为了让初学者更容易地在不同语言中过渡，这篇文章列出了一些常见的约定。&lt;/p&gt;
&lt;p&gt;&lt;span id=&quot;more-1059&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;1. 类属性名前加下划线&lt;/h2&gt;
&lt;p&gt;如果你看到一个变量或者方法是以_开头的，其实这并不代表其幕后有什么猫腻。这仅仅是为了提醒开发者这个变量/属性/方法是私有的（&lt;code&gt;private&lt;/code&gt;）或是受保护的（&lt;code&gt;protected&lt;/code&gt;），它们不能从类的外部访问到。&lt;/p&gt;
&lt;h4&gt;PHP方式&lt;/h4&gt;
&lt;pre class=&quot;brush: php; title: ; notranslate&quot; title=&quot;&quot;&gt;class MyClass {
   // 这个实例变量在类外部无法访问
   private $_someVariable;

   // 这个方法仅在类内部或者其它继承它的类中可用
   protected function __behindTheScenesMethod() {}
}&lt;/pre&gt;
&lt;h4&gt;JavaScript方式&lt;/h4&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var Female = (function() {
   var _trueAge = 50,
        _trueWeight = 140;

   return {
      age : _trueAge - 15,
      weight : _trueWeight - 30
   };
})();

Female.age; // 35
Female.weight; // 110
Female._trueAge; // 未定义（因为它是私有的，嘿嘿）&lt;/pre&gt;
&lt;p&gt;这里的Female并不是一个方法，但它返回一个对象（译注：这个例子很幽默）。这样，下划线前缀就可以提醒我们哪些是私有的。&lt;/p&gt;
&lt;h2&gt;2. 大写常量名&lt;/h2&gt;
&lt;p&gt;常量（&lt;code&gt;Constant&lt;/code&gt;）代表了一个不会改变的静态值。例如，假设一个项目中需要一个税率值.0825，它便是一个常量。然而，并非所有语言都支持这种类型。因此，最好的做法是全部使用大写字母来提醒自己这是个常量。在JavaScript中，语言内建的对象都是采用这种约定，例如&lt;code&gt;MATH.PI&lt;/code&gt;。&lt;/p&gt;
&lt;h4&gt;JavaScript方式&lt;/h4&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var TAXRATE = .0825;&lt;/pre&gt;
&lt;h4&gt;PHP方式&lt;/h4&gt;
&lt;pre class=&quot;brush: php; title: ; notranslate&quot; title=&quot;&quot;&gt;define('TAXRATE', .0825);&lt;/pre&gt;
&lt;h2&gt;3. 单字母前缀&lt;/h2&gt;
&lt;p&gt;你一定在某些场合见过变量名是以一个单独字母开头的，例如“s”或者“i”。&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ; notranslate&quot; title=&quot;&quot;&gt;$sName = 'Captain Jack Sparrow'; //译注：Jack Sparrow《加勒比海盗》中的船长角色&lt;/pre&gt;
&lt;p&gt;这被称作“匈牙利命名法”，事实上在近几年并不流行。不过在许多公司内这仍是一条约定。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;匈牙利命名法能够提醒开发者它正在使用的变量是什么类型的：&lt;code&gt;string&lt;/code&gt;，&lt;code&gt;integer&lt;/code&gt;等。&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;尤其在JavaScript中，这种方法是不可取的，因为JavaScript是弱类型的语言。弱类型语言不需要在使用变量前声明它的类型。如果我们给一个字符串以“s”开头命名，但是后来我们把一个整数赋值给它，这种命名法还有什么意义呢？事实上，这种形式的命名法会妨碍我们的工作，而不是对工作有益。&lt;/p&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var sName = &amp;quot;Lieutenant Commander Geordi La Forge&amp;quot;; // 译注：Geordi La Forge 少校是《星际迷航：下一代》中的角色，天生眼盲，佩戴高科技护目镜
typeof(sName); // string
....
sName = undefined;
typeof(sName) // undefined&lt;/pre&gt;
&lt;h3&gt;美元符号&lt;/h3&gt;
&lt;p&gt;致jQuery使用者：当你使用工厂函数生成对象并且心里暗喜没有受到匈牙利命名法的束缚时，你是否会在变量名前加一个美元符号？如果是这样，那么这也是匈牙利命名法的一种形式。这个符号的唯一目的是提醒你这个变量的类型。&lt;/p&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;// 这个美元符号提醒我可它可以使用jQuery的各种方法
var $container = $('#container');
&lt;/pre&gt;
&lt;h4&gt;应当这么使用吗？&lt;/h4&gt;
&lt;p&gt;这完全取决于你自己。事实上许多jQuery团队的成员也使用这种美元符号前缀。使用它的最终目的是能够适应你的工作。以我而言，几年前我就不使用这种美元符号了??这仅仅是因为我个人觉得这没有必要。你可以自己决定如何对待它。&lt;/p&gt;
&lt;h2&gt;4. 首字母大写&lt;/h2&gt;
&lt;p&gt;下面这个首字母大写的变量名看上去如何？&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ; notranslate&quot; title=&quot;&quot;&gt;$response = $SomeClass-&amp;gt;doSomething();&lt;/pre&gt;
&lt;p&gt;在上面的代码中，$SomeClass写成了单词首字母大写的形式是因为它是一个类的对象而不是普通的变量名。通常这是绝大多数开发者使用的方法。当我们一年后再回过头来看这些代码时，这个简单的形式就能准确地告诉我们这是一个对象，可以调用其方法。&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ; notranslate&quot; title=&quot;&quot;&gt;// 注意类名中大写的M
class MyClass {
   function __construct() {}
}&lt;/pre&gt;
&lt;h3&gt;JavaScript方式&lt;/h3&gt;
&lt;p&gt;在JavaScript中，没有真正的类，但是有构造（&lt;code&gt;constructor&lt;/code&gt;）函数。&lt;/p&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var Jeff = new Person();&lt;/pre&gt;
&lt;p&gt;我们将构造器（&lt;code&gt;Person&lt;/code&gt;）的首字母大写的原因是我们有时候很容易忘记new关键词。在这种情况下，JavaScript往往不会抛出任何警告，但是这个小错误却非常难调试到。首字母大写能够给开发者在debug时一个有效的提示。Douglas Crockford是这个约定最大的提倡者。（译注：Douglas Crockford是Javascript社区的大神级人物，是&lt;a href=&quot;http://www.json.org/json-zh.html&quot;&gt;JSON&lt;/a&gt;、&lt;a href=&quot;http://www.jslint.com/&quot;&gt;JSLint&lt;/a&gt;、&lt;a href=&quot;http://www.crockford.com/javascript/jsmin.html&quot;&gt;JSMin&lt;/a&gt;和&lt;a href=&quot;http://www.adsafe.org/&quot;&gt;ADSafe&lt;/a&gt;之父，是《&lt;a title=&quot;JavaScript: the good parts&quot; href=&quot;http://books.google.com/books?id=PXa2bby0oQ0C&amp;amp;printsec=frontcover&amp;amp;hl=zh-CN&amp;amp;source=gbs_ge_summary_r&amp;amp;cad=0#v=onepage&amp;amp;q&amp;amp;f=false&quot; target=&quot;_blank&quot;&gt;JavaScript：The Good Parts&lt;/a&gt;》的作者。）&lt;/p&gt;
&lt;p&gt;另一种可选方案是，如果你生怕自己的健忘，你可以在执行前首先确保构造器存在并且正确。&lt;/p&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;function Person(name) {
  // 如果遗漏了new关键词，将会执行下面的构造函数并返回一个新的实例
  if ( this.constructor !== Person ) {
    return new Person(name);
  }
 this.name = name;
}

// 故意不用“new”关键词
var Joey = Person('Joey');
Joey.name; // Joey
&lt;/pre&gt;
&lt;h2&gt;5. 驼峰式和下划线式&lt;/h2&gt;
&lt;p&gt;为什么有些变量使用驼峰式大小写模式，而有些是使用下划线分割单词呢？哪一种是正确的方法？答案是：没有绝对正确的用法。这完全去取决于你的语言，或者你公司的代码约定。这两种都是非常好的方式。&lt;/p&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;// camelCase
var preacherOfSockChanging = 'Lieutenant Dan'; // 译注：Dan中尉，电影《阿甘正传》中的人物

// under_score
var preacher_of_sock_changing = 'Lieutenant Dan';&lt;/pre&gt;
&lt;p&gt;正如大家所说，跟随你使用的语言的通常约定是一项最佳实践。例如，大量JavaScript开发者使用驼峰式的语法，而像PHP则更倾向于使用下划线分割。需要重申的是，这不是板上钉钉的规矩。Zend框架就是驼峰式大小写的推动者。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;比你使用什么更重要的是确保你一直去使用它！&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2&gt;6. 目录结构&lt;/h2&gt;
&lt;p&gt;通常在团队中工作时，你必须和你的协同开发者一起接受一个合适的目录结构。最基本的显然是不要把所有的样式表、脚本都放到项目的根目录下，这显得非常无组织无纪律。许多开发者愿意将它们的图像、脚本和样式表放到一个&lt;code&gt;Assets&lt;/code&gt;目录下。&lt;/p&gt;
&lt;pre class=&quot;brush: plain; title: ; notranslate&quot; title=&quot;&quot;&gt;/ Project Root
  /Assets
    / js
      / min
        script_min.js
      script.js
    / css
      / min
        style_min.css
      style.css
    / img
      img1.jpg
  index.html
  otherFile.html&lt;/pre&gt;
&lt;p&gt;此外，记住一项创建&lt;code&gt;min&lt;/code&gt;目录的约定规则。这里面动态地存放着压缩后的脚本和样式表文件。&lt;/p&gt;
&lt;h2&gt;7. 语义&lt;/h2&gt;
&lt;p&gt;当使用标记语言时，需要明白你选择的&lt;code&gt;id&lt;/code&gt;和&lt;code&gt;class&lt;/code&gt;需要能够描述你的内容，而不是仅仅代表形式。例如：&lt;/p&gt;
&lt;h4&gt;最悲剧的&lt;/h4&gt;
&lt;pre class=&quot;brush: xml; title: ; notranslate&quot; title=&quot;&quot;&gt;&amp;lt;div id=&amp;quot;middle-left-and-then-a-little-lower&amp;quot;&amp;gt; Justin Bieber is my homeboy section. &amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;h4&gt;稍好一些&lt;/h4&gt;
&lt;pre class=&quot;brush: xml; title: ; notranslate&quot; title=&quot;&quot;&gt;&amp;lt;div class=&amp;quot;section&amp;quot;&amp;gt; Justin Bieber is my homeboy section. &amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;h4&gt;最佳做法&lt;/h4&gt;
&lt;pre class=&quot;brush: xml; title: ; notranslate&quot; title=&quot;&quot;&gt;&amp;lt;section&amp;gt; Justin Bieber is my homeboy section. &amp;lt;/section&amp;gt;  &lt;/pre&gt;
&lt;p&gt;怎么样？如果在六个月以后，你决定把Justin Bieber粉丝的内容放到中间偏右并稍低一些（middle-RIGHT-and-then-a-little-lower）的位置呢？这样，你的i&lt;code&gt;id&lt;/code&gt;就完全失去了意义。&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;我们正在向HTML5的世界过渡，你应当在元素中使用尽量少的标识。&lt;code&gt;id&lt;/code&gt;显得很不灵活，而且很多情况下并不需要。&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2&gt;8. 写两遍&lt;code&gt;Header&lt;/code&gt;和&lt;code&gt;Footer&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;当做一个居中的网站时，需要将多重背景扩展到整个窗口的宽度（通常是&lt;code&gt;header&lt;/code&gt;和&lt;code&gt;footer&lt;/code&gt;），是非常令人讨厌的。你通常需要包裹你的内容，这样外层元素扩展后，内层元素还能继续保持居中。&lt;/p&gt;
&lt;p&gt;这是一个一般性的问题，在创建必需的标记语言内容时接受这样的约定规则是很重要的。&lt;/p&gt;
&lt;pre class=&quot;brush: xml; title: ; notranslate&quot; title=&quot;&quot;&gt;&amp;lt;div id=&amp;quot;footer-wrap&amp;quot;&amp;gt;
	&amp;lt;footer&amp;gt;
	  My footer content goes here.
	&amp;lt;/footer&amp;gt;
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;难以决定的是，假设你在使用HTML5中的新元素，你需要决定将&lt;code&gt;footer&lt;/code&gt;标签放在里面还是外面。这个还有待讨论。然而我个人觉得将&lt;code&gt;footer&lt;/code&gt;放在内层更加语义化。&lt;/p&gt;
&lt;p&gt;&lt;code&gt;div&lt;/code&gt;只限下面的情况时才使用：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;没有更好的元素来使用了&lt;/li&gt;
&lt;li&gt;你需要一个单纯的表示布局结构的元素&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;9. 简写&lt;/h2&gt;
&lt;p&gt;现在就决定是否允许在你的代码中使用简写。书写精确且整洁的代码总是一场可读性和代码长度的斗争。这也正是开发团队内使用相同代码风格是首要考虑规则的原因。来看两个简单的例子：&lt;/p&gt;
&lt;h4&gt;三目运算符合适吗？&lt;/h4&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var name = 'Joe';

// regular
if ( name === 'Jeff' ) {
  alert(&amp;quot;That's me&amp;quot;);
} else {
  alert(&amp;quot;Nope&amp;quot;);
}

// ternary
alert(name === &amp;quot;Jeff&amp;quot; ? &amp;quot;That's me&amp;quot; : &amp;quot;Nope&amp;quot;); // Nope&lt;/pre&gt;
&lt;h4&gt;使用逻辑&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;来写简短的条件判断句？&lt;/h4&gt;
&lt;pre class=&quot;brush: jscript; title: ; notranslate&quot; title=&quot;&quot;&gt;var getTweets = true;

// regular
if ( getTweets ) {
 alert('getting them now');
}

// 逻辑 AND
// 除非左边是“true”否则右边不会运行
getTweets &amp;amp;&amp;amp; alert('Getting them now');&lt;/pre&gt;
&lt;p&gt;许多开发者都对如此使用AND感到不爽，坚持认为这影响了可读性。尽管这的确是是一个有力的观点，但是连流行的框架类库例如jQuery也大量使用了这种方法。&lt;/p&gt;
&lt;h2&gt;结论&lt;/h2&gt;
&lt;p&gt;再次重申，你在开发时坚持使用某种方式比选择什么样的的约定来的更加重要。事实上，许多开发团队都有自己专门的代码风格指导给新开发者参考。感谢阅读！&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;译注：关于变量命名更详细的约定规则介绍，大家可以阅读《代码大全》（第2版）的第11章。&lt;/p&gt;
&lt;p&gt;原文：&lt;a title=&quot;9 Confusing Naming Conventions for Beginners&quot; href=&quot;http://net.tutsplus.com/articles/general/9-confusing-naming-conventions-for-beginners/&quot; target=&quot;_blank&quot;&gt;9 Confusing Naming Conventions for Beginners&lt;/a&gt;&lt;br /&gt;
作者：&lt;a title=&quot;Jeffrey Way&quot; href=&quot;http://net.tutsplus.com/author/jeffreyway/&quot;&gt;Jeffrey Way&lt;/a&gt;&lt;/p&gt;
</content>
    </entry>
  
    <entry>
      <title>Node.js使用 Mustache.js做模板</title>
      <link href="http://lxj.name/javascript/2012/03/12/nodejs-mustache-template.html"/>
      <updated>2012-03-12T00:00:00-07:00</updated>
      <id>http://lxj.name/javascript/2012/03/12/nodejs-mustache-template</id>
      <content type="html">&lt;p&gt;From:&lt;a href=&quot;http://www.oschina.net/question/12_21806&quot; target=&quot;_blank&quot;&gt;http://www.oschina.net/question/12_21806&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;为了让 Node.js 输出更多的 HTML 元素，我们可以借助一些 html 模板引擎，例如 Mustache。&lt;/p&gt; 
&lt;p&gt;首先在 Node.js 中安装 Mustache：&lt;/p&gt; 
&lt;p&gt;npm install mustache&lt;/p&gt; 
&lt;p&gt;这会创建一个目录：node_modules\mustache&lt;/p&gt; 
&lt;p&gt;然后我们可以编写代码：&lt;/p&gt; 
&lt;pre class=&quot;brush:js; toolbar: true; auto-links: false;&quot;&gt;    var mustache = require('./node_modules/mustache/mustache');
     
    function helloworld(response)
    {
      console.log('request recieved at ' + (new Date()).getTime());
      response.writeHead(200, {'Content-Type': 'text/html'});
      var template = '&amp;lt;h1&amp;gt;Test&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;';
      var model = {helloworld:'Hello World'};
      response.end(mustache.to_html(template,model));
    }
     
    exports.helloworld = helloworld;&lt;/pre&gt; 
&lt;p&gt;这段代码使用 to_html 函数生成网页，来看看执行效果：&lt;/p&gt; 
&lt;p&gt;&lt;img width=&quot;850&quot; alt=&quot;&quot; src=&quot;http://assets.xmlhtml.cn/img/14105211_OguQ.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;但这看起来很不爽，我们希望模板独立于控制器之外，例如下面的模板：&lt;/p&gt; 
&lt;pre class=&quot;brush:html; toolbar: true; auto-links: false;&quot;&gt;    &amp;lt;html&amp;gt;
      &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;My first template&amp;lt;/title&amp;gt;
      &amp;lt;/head&amp;gt;
      &amp;lt;body&amp;gt;
        &amp;lt;h1&amp;gt;Test&amp;lt;/h1&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;&lt;/pre&gt; 
&lt;p&gt;文件名是 helloworld.html.&lt;/p&gt; 
&lt;p&gt;为了使用这个模板文件，我们可以这样编写代码：&lt;/p&gt; 
&lt;pre class=&quot;brush:js; toolbar: true; auto-links: false;&quot;&gt;    var mustache = require('./node_modules/mustache/mustache');
    var fs = require('fs');
     
    function helloworld(response)
    {
      console.log('request recieved at ' + (new Date()).getTime());
      fs.readFile(&amp;quot;./helloworld.html&amp;quot;,function(err,template) {
                response.writeHead(200, {'Content-Type': 'text/html'})
                response.write(mustache.to_html(template.toString(), {helloworld:&amp;quot;Hello World&amp;quot;}))
                response.end()
         });
    }
     
    exports.helloworld = helloworld;&lt;/pre&gt; 
&lt;p&gt;运行结果如下：&lt;/p&gt; 
&lt;p&gt;&lt;img width=&quot;850&quot; alt=&quot;&quot; src=&quot;http://assets.xmlhtml.cn/img/14105214_UPGS.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;怎样，简单很多吧？:)&lt;/p&gt;</content>
    </entry>
  
    <entry>
      <title>Jekyll Pagination</title>
      <link href="http://lxj.name/other/2012/03/09/jekyll-pagination.html"/>
      <updated>2012-03-09T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2012/03/09/jekyll-pagination</id>
      <content type="html">&lt;p&gt;From:&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki/Usage&quot;&gt;https://github.com/mojombo/jekyll/wiki/Usage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Pagination does not work with markdown files, it only works with html file extensions.&lt;/p&gt;

&lt;p&gt;Just follow these steps to add pagination to your blog:&lt;/p&gt;

&lt;h2&gt;_config.yml&lt;/h2&gt;

&lt;p&gt;add the pagination setting:
&lt;code&gt;yaml
markdown: rdiscount
pygments: true
lsi: true
exclude: ['README.markdown', 'README_FOR_COLLABORATORS.markdown', 'Gemfile.lock', 'Gemfile']
production: false
//add this line to add pagination
paginate: 3 //the number of post per page
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;index.html&lt;/h2&gt;

&lt;p&gt;just add the posts and the pagination links:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;---
layout: default
title: Blog
---



&amp;lt;!-- Pagination links --&amp;gt;
&amp;lt;div class=&quot;pagination&quot;&amp;gt;

    &amp;lt;span class=&quot;previous&quot;&amp;gt;Previous&amp;lt;/span&amp;gt;

  &amp;lt;span class=&quot;page_number &quot;&amp;gt;Page:  of &amp;lt;/span&amp;gt;

    &amp;lt;span class=&quot;next &quot;&amp;gt;Next&amp;lt;/span&amp;gt;

&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;A note about page1&lt;/h2&gt;

&lt;p&gt;Jekyll does not produce a page1 folder so using the above code will not work when a link is produced of the form &quot;/page1&quot;. The following textile will handle page1 and render a list of each page with links to all but the current page.&lt;/p&gt;

&lt;p&gt;``` textile&lt;/p&gt;

&lt;div id=&quot;post-pagination&quot; class=&quot;pagination&quot;&gt;

  
  &lt;p class=&quot;previous disabled&quot;&gt;
    &lt;span&gt;Previous&lt;/span&gt;
  &lt;/p&gt;
  

  &lt;ul class=&quot;pages&quot;&gt;
    &lt;li class=&quot;page&quot;&gt;
      
      &lt;a href=&quot;/&quot;&gt;1&lt;/a&gt;
      
    &lt;/li&gt;

    
  &lt;/ul&gt;

  
  &lt;p class=&quot;next disabled&quot;&gt;
    &lt;span&gt;Next&lt;/span&gt;
  &lt;/p&gt;
  

&lt;/div&gt;


&lt;p&gt;```&lt;/p&gt;
</content>
    </entry>
  
    <entry>
      <title>Jekyll Usage</title>
      <link href="http://lxj.name/other/2012/03/08/jekyll-usage.html"/>
      <updated>2012-03-08T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2012/03/08/jekyll-usage</id>
      <content type="html">&lt;p&gt;From:&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki/Usage&quot;&gt;https://github.com/mojombo/jekyll/wiki/Usage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Creating a Jekyll site usually involves the following, [[once jekyll is installed.|Install]]&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up the basic structure of the site&lt;/li&gt;
&lt;li&gt;Create some posts, or [[import them from your previous platform|Blog migrations]]&lt;/li&gt;
&lt;li&gt;Run your site locally to see how it looks&lt;/li&gt;
&lt;li&gt;Deploy your site&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;Basic Structure&lt;/h2&gt;

&lt;p&gt;Jekyll at its core is a text transformation engine. The concept behind the system is this: you give it text written in your favorite markup language, be that Markdown, Textile, or just plain HTML, and it churns that through a layout or series of layout files. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed on the layout and more. This is all done through strictly editing files, and the web interface is the final product.&lt;/p&gt;

&lt;p&gt;A basic Jekyll site usually looks something like this:&lt;/p&gt;

&lt;pre&gt;
.
|-- _config.yml
|-- _includes
|-- _layouts
|   |-- default.html
|   `-- post.html
|-- _posts
|   |-- 2007-10-29-why-every-programmer-should-play-nethack.textile
|   `-- 2009-04-26-barcamp-boston-4-roundup.textile
|-- _site
`-- index.html
&lt;/pre&gt;


&lt;p&gt;An overview of what each of these does:&lt;/p&gt;

&lt;h3&gt;_config.yml&lt;/h3&gt;

&lt;p&gt;Stores [[configuration|Configuration]] data. A majority of these options can be specified from the command line executable but it's easier to throw them in here so you don't have to remember them.&lt;/p&gt;

&lt;h3&gt;_includes&lt;/h3&gt;

&lt;p&gt;These are the partials that can be mixed and matched by your &lt;em&gt;layouts and &lt;/em&gt;posts to facilitate reuse.  The liquid tag &lt;code&gt;Included file 'file.ext' not found in &lt;em&gt;includes directory&lt;/code&gt; can be used to include the partial in &lt;/em&gt;includes/file.ext.&lt;/p&gt;

&lt;h3&gt;_layouts&lt;/h3&gt;

&lt;p&gt;These are the templates which posts are inserted into. Layouts are defined on a post-by-post basis in the [[YAML front matter]], which is described in the next section. The liquid tag &lt;code&gt;&lt;/code&gt; is used to inject data onto the page.&lt;/p&gt;

&lt;h3&gt;_posts&lt;/h3&gt;

&lt;p&gt;Your dynamic content, so to speak. The format of these files is important, as named as &lt;code&gt;YEAR-MONTH-DAY-title.MARKUP&lt;/code&gt;. The [[Permalinks|permalinks]] can be adjusted very flexibly for each post, but the date and markup language are determined solely by the file name.&lt;/p&gt;

&lt;h3&gt;_site&lt;/h3&gt;

&lt;p&gt;This is where the generated site will be placed once Jekyll is done transforming it. It's probably a good idea to add this to your &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;index.html and Other HTML/Markdown/Textile Files&lt;/h3&gt;

&lt;p&gt;Provided that the file has a [[YAML Front Matter]] section, it will be transformed by Jekyll. The same will happen for any &lt;code&gt;.html&lt;/code&gt;, &lt;code&gt;.markdown&lt;/code&gt;, or &lt;code&gt;.textile&lt;/code&gt; file in your site's root directory or directories not listed above.&lt;/p&gt;

&lt;h3&gt;Other Files/Folders&lt;/h3&gt;

&lt;p&gt;Every other directory and file except for those listed above will be transferred over as expected. For example, you could have a &lt;code&gt;css&lt;/code&gt; folder, a &lt;code&gt;favicon.ico&lt;/code&gt;, etc, etc. There's [[plenty of sites|Sites]] already using Jekyll if you're curious as to how they're laid out.&lt;/p&gt;

&lt;p&gt;Any files in these directories will be parsed and transformed, according to the same rules mentioned previously for files in the root directory.&lt;/p&gt;

&lt;h3&gt;Running Jekyll&lt;/h3&gt;

&lt;p&gt;Usually this is done through the &lt;code&gt;jekyll&lt;/code&gt; executable, which is installed with the gem. In order to get a server up and running with your Jekyll site, run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jekyll --server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and then browse to http://0.0.0.0:4000. There's plenty of [[configuration options|Configuration]] available to you as well.&lt;/p&gt;

&lt;p&gt;On Debian or Ubuntu, you may need to add &lt;code&gt;/var/lib/gems/1.8/bin/&lt;/code&gt; to your path.&lt;/p&gt;

&lt;h3&gt;base-url option&lt;/h3&gt;

&lt;p&gt;If you are using base-url option like&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jekyll --server --base-url '/blog'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then make sure that you access the site at&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:4000/blog/index.html&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;Just accessing&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:4000/blog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;will not work.&lt;/p&gt;

&lt;h3&gt;Deployment&lt;/h3&gt;

&lt;p&gt;Since Jekyll simply generates a folder filled with HTML files, it can be served using practically any available web server out there. Please check the [[Deployment]] page for more information regarding specific scenarios.&lt;/p&gt;
</content>
    </entry>
  
    <entry>
      <title>Jekyll Template data</title>
      <link href="http://lxj.name/other/2012/03/08/jekyll-template-data.html"/>
      <updated>2012-03-08T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2012/03/08/jekyll-template-data</id>
      <content type="html">&lt;p&gt;From:&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki/Template-Data&quot;&gt;https://github.com/mojombo/jekyll/wiki/Template-Data&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Jekyll traverses your site looking for files to process. Any files with [[&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt; Front Matter]] are subject to processing. For each of these files, Jekyll makes a variety of data available to the pages via the &lt;a href=&quot;http://wiki.github.com/shopify/liquid/liquid-for-designers&quot;&gt;Liquid templating system&lt;/a&gt;. The following is a reference of the available data.&lt;/p&gt;
&lt;h2&gt;Global&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;strong&gt;Variable&lt;/strong&gt; &lt;/td&gt;
		&lt;td&gt; &lt;strong&gt;Description&lt;/strong&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Sitewide information + Configuration settings from &lt;code&gt;_config.yml&lt;/code&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;page&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; This is just the [[&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt; Front Matter]] with 2 additions: &lt;code&gt;url&lt;/code&gt; and &lt;code&gt;content&lt;/code&gt;. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;content&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; In layout files, this contains the content of the subview(s). This is the variable used to insert the rendered content into the layout. This is not used in post files or page files. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator&lt;/code&gt;&lt;/td&gt;
		&lt;td&gt; When the &lt;code&gt;paginate&lt;/code&gt; configuration option is set, this variable becomes available for use. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;h2&gt;Site&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;strong&gt;Variable&lt;/strong&gt; &lt;/td&gt;
		&lt;td&gt; &lt;strong&gt;Description&lt;/strong&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.time&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The current Time (when you run the jekyll command). &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.posts&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; A reverse chronological list of all Posts. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.related_posts&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt;If the page being processed is a Post, this contains a list of up to ten related Posts. By default, these are low quality but fast to compute. For high quality but slow to compute results, run the jekyll command with the &lt;code&gt;--lsi&lt;/code&gt; (latent semantic indexing) option. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.categories.CATEGORY&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The list of all Posts in category &lt;code&gt;CATEGORY&lt;/code&gt;. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.tags.TAG&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The list of all Posts with tag &lt;code&gt;TAG&lt;/code&gt;. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;site.[CONFIGURATION_DATA]&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; As of &lt;strong&gt;0.5.2&lt;/strong&gt;, all data inside of your &lt;code&gt;_config.yml&lt;/code&gt; is now available through the &lt;code&gt;site&lt;/code&gt; variable. So for example, if you have &lt;code&gt;url: http://mysite.com&lt;/code&gt; in your configuration file, then in your posts and pages it can be used like so: &lt;code&gt;http://www.lxj.com&lt;/code&gt;. Jekyll does not parse a changed &lt;code&gt;_config.yml&lt;/code&gt; in &lt;code&gt;auto&lt;/code&gt; mode, you have to restart jekyll. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;h2&gt;Page&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;strong&gt;Variable&lt;/strong&gt; &lt;/td&gt;
		&lt;td&gt; &lt;strong&gt;Description&lt;/strong&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;page.url&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; of the Page without the domain. e.g. &lt;code&gt;/es/index.html&lt;/code&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;page.content&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The un-rendered content of the Page. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Note: Any custom front matter that you specify will be available under &lt;code&gt;page&lt;/code&gt;. For example, if you specify &lt;code&gt;custom_css: true&lt;/code&gt; in a page&amp;#8217;s front matter, that value will be available in templates as &lt;code&gt;page.custom_css&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;Post&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;strong&gt;Variable&lt;/strong&gt; &lt;/td&gt;
		&lt;td&gt; &lt;strong&gt;Description&lt;/strong&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.title&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The title of the Post. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.url&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; of the Post without the domain. e.g. &lt;code&gt;/2008/12/14/my-post.html&lt;/code&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.date&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The Date assigned to the Post. This can be overridden in a post&amp;#8217;s front matter by specifying a new date/time in the format &lt;code&gt;YYYY-MM-DD HH:MM:SS&lt;/code&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.id&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; An identifier unique to the Post (useful in &lt;span class=&quot;caps&quot;&gt;RSS&lt;/span&gt; feeds). e.g. &lt;code&gt;/2008/12/14/my-post&lt;/code&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.categories&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The list of categories to which this post belongs. Categories are derived from the directory structure above the _posts directory. For example, a post at &lt;code&gt;/work/code/_posts/2008-12-24-closures.textile&lt;/code&gt; would have this field set to &lt;code&gt;['work', 'code']&lt;/code&gt;. These can also be specified in the [[&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt; Front Matter]] &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.tags&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The list of tags to which this post belongs. These can be specified in the [[&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt; Front Matter]] &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;post.content&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The rendered content of the Post. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;h2&gt;Paginator&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;note: only available in index files, can be in subdirectory /blog/index.html&lt;/strong&gt;&lt;/p&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;strong&gt;Variable&lt;/strong&gt; &lt;/td&gt;
		&lt;td&gt; &lt;strong&gt;Description&lt;/strong&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.per_page&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Number of posts per page. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.posts&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Posts available for that page. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.total_posts&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Total number of posts. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.total_pages&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Total number of pages. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.page&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The number of the current page. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.previous_page&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The number of the previous page. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;paginator.next_page&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; The number of the next page. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;</content>
    </entry>
  
    <entry>
      <title>Jekyll YAML Front Matter</title>
      <link href="http://lxj.name/other/2012/03/08/jekyll-YAML-Front-Matter.html"/>
      <updated>2012-03-08T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2012/03/08/jekyll-YAML-Front-Matter</id>
      <content type="html">&lt;p&gt;From:&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter&quot;&gt;https://github.com/mojombo/jekyll/wiki/&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt;-Front-Matter&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Any files that contain a &lt;a href=&quot;http://yaml.org/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt;&lt;/a&gt; front matter block will be processed by Jekyll as special files. The front matter must be the first thing in the file and takes the form of:&lt;/p&gt;
&lt;pre&gt;
---
layout: post
title: Blogging Like a Hacker
---
&lt;/pre&gt;
&lt;p&gt;Between the triple-dashed lines, you can set predefined variables (see below for a reference) or custom data of your own.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;IMPORTANT&lt;/span&gt;! (Especially for Windows users)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When you use &lt;code&gt;UTF-8&lt;/code&gt; encoding for your file, make it clear that no &lt;code&gt;BOM&lt;/code&gt; header chars in your file. Or everything will blow up!&lt;/p&gt;
&lt;h2&gt;Predefined Global Variables&lt;/h2&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; Variable &lt;/td&gt;
		&lt;td&gt; Description &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;layout&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; If set, this specifies the layout file to use. Use the layout file name without file extension. Layout files must be placed in the &lt;code&gt;_layouts&lt;/code&gt; directory. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;permalink&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; If you need your processed URLs to be something other than the default /year/month/day/title.html then you can set this variable and it will be used as the final &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt;. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;published&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Set to false if you don&amp;#8217;t want a post to show up when the site is generated. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;category&lt;/code&gt;/&lt;code&gt;categories&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Instead of placing posts inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally.&lt;br /&gt;Categories can be specified as a &lt;a href=&quot;http://en.wikipedia.org/wiki/YAML#Lists&quot;&gt;&lt;span class=&quot;caps&quot;&gt;YAML&lt;/span&gt; list.&lt;/a&gt; &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;tags&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; Similar to categories, 1 or multiple tags can be added to a post. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;h2&gt;Custom Variables&lt;/h2&gt;
&lt;p&gt;Any variables in the front matter that are not predefined are mixed into the data that is sent to the Liquid templating engine during the conversion. For instance, if you set a title, you can use that in your layout to set the page title:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;title&amp;gt;Jekyll YAML Front Matter&amp;lt;/title&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;Predefined Variables for Post Front-Matter&lt;/h2&gt;
&lt;p&gt;These are available out-of-the-box to be used in the front-matter for a post.&lt;/p&gt;
&lt;table&gt;
	&lt;tr&gt;
		&lt;td&gt; Variable &lt;/td&gt;
		&lt;td&gt; Description &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt; &lt;code&gt;date&lt;/code&gt; &lt;/td&gt;
		&lt;td&gt; A date here overrides the date from the name of the post. This can be used to ensure correct sorting of posts. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;</content>
    </entry>
  
    <entry>
      <title>.html模板测试</title>
      <link href="http://lxj.name/linux/2012/03/05/test.html"/>
      <updated>2012-03-05T00:00:00-08:00</updated>
      <id>http://lxj.name/linux/2012/03/05/test</id>
      <content type="html">        &lt;p&gt;Jekyll是一个使用Ruby编写的静态站点生成工具，使用Liquid模板渲染引擎，支持Markdown和Textile标记语言，并且可以为所有以 .html、.markdown、.textile扩展名结尾的文件使用YAML配置，内置语法高亮功能。而Github的Pages服务可以为每个Github主机上的仓库提供静态页面服务，并且Pages服务支持Jekyll。因为Github Pages有两种Pages，分别是用户页面和项目页面，所以我们可以使用用户页面来创建自己的Blog。&lt;/p&gt;

      &lt;p&gt;在开始前，请确保你已经有了Github账号一枚和Git的正确配置。没有的朋友可以先移步&lt;a href=&quot;https://github.com/plans&quot;&gt;Github注册&lt;/a&gt;并&lt;a href=&quot;http://help.github.com/win-set-up-git/&quot;&gt;安装配置Git&lt;/a&gt;。&lt;/p&gt;

      &lt;p&gt;首先，创建你的 Blog 仓库 username(请确保跟你的账号名相同).github.com:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ mkdir username.github.com
        $ cd username.github.com
      &lt;/pre&gt;


      &lt;p&gt;新建一个 index.html 文件，像下面这样:&lt;/p&gt;

      &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;&lt;span class=&quot;lineno&quot;&gt; 1&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 3&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 4&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 5&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 6&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 7&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 8&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello!&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 9&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
      &lt;/code&gt;&lt;/pre&gt;
      &lt;/div&gt;


      &lt;p&gt;初始化仓库、提交并push到Github:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ git init
        $ git add .
        $ git commit -a -m 'init commit.'
        $ git remote add origin
        $ git push origin master
      &lt;/pre&gt;


      &lt;p&gt;现在你打开 username.github.com 就可以看到刚才新建的页面了，就是这么简单。当然也可以为你的Blog仓库绑定独立域名，具体做法就是：&lt;/p&gt;

      &lt;ol&gt;
      &lt;li&gt;在你的仓库中新建内容为 www.youdomain.com 的 CNAME 文件；&lt;/li&gt;
      &lt;li&gt;在你的域名管理页或者是DNS解析的地方，增加一个记录，记录类别为CNAME(Alias)类型.&lt;/li&gt;
      &lt;/ol&gt;


      &lt;p class=&quot;note&quot;&gt;*Note：如果你在CNAME中填写的是顶级域名，就得设置DNS的记录类别为A(Host)型，并设置主机为207.97.227.245。详细介绍请移步Github的&lt;a href=&quot;http://pages.github.com&quot;&gt;Pages&lt;/a&gt;页面。&lt;/p&gt;


      &lt;p&gt;接下来我们只需要按照自己的喜好设计页面。首先认识下Jekyll的文件及目录配置:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        .
        |-- _includes
        |-- _plugins
        |-- _layout
        |   |-- default.html
        |   `-- post.html
        |-- _post
        |   |-- yyyy-mm-dd-title.markdown
        |   `-- yyyy-mm-dd-title.markdown
        |-- _site
        |-- _config.yml
        `-- index.html
      &lt;/pre&gt;


      &lt;h2&gt;_includes&lt;/h2&gt;

      &lt;p&gt;存放你需要在模板文件中包含的文件，你可以使用Liquid标签 &lt;code&gt;{&amp;permil; include file.ext &amp;permil;}&lt;/code&gt; 来引用相应的文件。&lt;/p&gt;

      &lt;h2&gt;_plugins&lt;/h2&gt;

      &lt;p&gt;可以增加你自己的插件&lt;/p&gt;

      &lt;h2&gt;_layout&lt;/h2&gt;

      &lt;p&gt;存放布局模板，请参考&lt;a href=&quot;https://github.com/taberhuang/taberhuang.github.com/tree/master/_layouts&quot;&gt;https://github.com/taberhuang/taberhuang.github.com/tree/master/_layouts&lt;/a&gt;&lt;/p&gt;

      &lt;h2&gt;_post&lt;/h2&gt;

      &lt;p&gt;存放文章列表，文件命名一定要遵循 yyyy-mm-dd-title.html|markdown|textile 规则，请参考&lt;a href=&quot;https://github.com/taberhuang/taberhuang.github.com/tree/master/_posts&quot;&gt;https://github.com/taberhuang/taberhuang.github.com/tree/master/_posts&lt;/a&gt;&lt;/p&gt;

      &lt;h2&gt;_site&lt;/h2&gt;

      &lt;p&gt;Jekyll自动生成的，所以可以忽略，如果你有在本地安装Jekyll并预览了的话，可以使用.gitignore设置Git停止对本目录的跟踪。&lt;/p&gt;

      &lt;h2&gt;_config.yml&lt;/h2&gt;

      &lt;p&gt;设置经常使用的配置选项，这样在本地启动预览时就不用每次都手动输入了。&lt;/p&gt;

      &lt;h2&gt;index.html 和所有的 HTML/Markdown/Textile 文件&lt;/h2&gt;

      &lt;p&gt;所有的HTML/Markdown/Textile文件都可以包含 YAML 配置，这类文件都会被Jekyll解析。&lt;/p&gt;

      &lt;p&gt;现在你可以在自己的仓库中配置好你自己的目录及文件，也可以clone我的仓库，然后修改。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ git clone https://github.com/taberhuang/taberhuang.github.com.git
      &lt;/pre&gt;


      &lt;p&gt;修改完后就可以push你的代码到Github上，看到结果了。刚才有说到本地预览，如果你想在本地预览后，确保没错误再push的话，就需要在本地安装Jekyll，下面介绍下Jekyll的安装方法。&lt;/p&gt;

      &lt;p&gt;一、安装Ruby运行环境和RubyGem:Windows用户只要下载 &lt;a href=&quot;http://rubyforge.org/frs/download.php/74298/rubyinstaller-1.9.2-p180.exe&quot; title=&quot;点击下载&quot;&gt;RubyInstaller&lt;/a&gt;。下载安装后请手动升级gem.&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem update --system
      &lt;/pre&gt;


      &lt;p&gt;二、安装DevKit。&lt;a href=&quot;http://cloud.github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe&quot; target=&quot;_blank&quot;&gt;下载DevKit&lt;/a&gt;,DevKit是windows平台编译和使用本地C/C++扩展包工具。用来模拟Linux平台下的 &lt;code&gt;make,gcc,sh&lt;/code&gt; 进行编译。下载文件后，解压到 `C:\DevKit'，再通过命令行安装:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ cd C:\DevKit
        $ ruby dk.rb init
        $ ruby dk.rb install
      &lt;/pre&gt;


      &lt;p&gt;三、安装并检查刚才的DevKit安装是否成功。如果成功安装，则DevKit也就安装成功，如果不成功，请重新安装DevKit。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem install jekyll
      &lt;/pre&gt;


      &lt;p&gt;四、安装Rdiscount，这个是用来解析Markdown标记的解析包。如果你使用Textile的话，就是安装Kramdown。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem install rdiscount
      &lt;/pre&gt;


      &lt;p&gt;所有的环境和依赖包都安装成功后，进入你的仓库目录，用下面的命令便可启动Jekyll，并在本地预览了，预览地址默认为 &lt;code&gt;127.0.0.1:4000&lt;/code&gt;，当然你也可以通过 _config.yml 配置:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        jekyll --server
      &lt;/pre&gt;


      &lt;p&gt;是不是很爽?&lt;/p&gt;

      &lt;div style=&quot;margin-top:20px&quot;&gt;参考及相关资料：&lt;/div&gt;


      &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;http://pages.github.com/&quot;&gt;http://pages.github.com/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki&quot;&gt;https://github.com/mojombo/jekyll/wiki&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blog.envylabs.com/2009/08/publishing-a-blog-with-github-pages-and-jekyll/&quot;&gt;http://blog.envylabs.com/2009/08/publishing-a-blog-with-github-pages-and-jekyll/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://daringfireball.net/projects/markdown/syntax&quot;&gt;http://daringfireball.net/projects/markdown/syntax&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;

</content>
    </entry>
  
    <entry>
      <title>使用Jekyll搭建静态博客</title>
      <link href="http://lxj.name/other/2012/03/04/jekyll-blogs.html"/>
      <updated>2012-03-04T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2012/03/04/jekyll-blogs</id>
      <content type="html">        &lt;p&gt;Jekyll是一个使用Ruby编写的静态站点生成工具，使用Liquid模板渲染引擎，支持Markdown和Textile标记语言，并且可以为所有以 .html、.markdown、.textile扩展名结尾的文件使用YAML配置，内置语法高亮功能。而Github的Pages服务可以为每个Github主机上的仓库提供静态页面服务，并且Pages服务支持Jekyll。因为Github Pages有两种Pages，分别是用户页面和项目页面，所以我们可以使用用户页面来创建自己的Blog。&lt;/p&gt;

      &lt;p&gt;在开始前，请确保你已经有了Github账号一枚和Git的正确配置。没有的朋友可以先移步&lt;a href=&quot;https://github.com/plans&quot;&gt;Github注册&lt;/a&gt;并&lt;a href=&quot;http://help.github.com/win-set-up-git/&quot;&gt;安装配置Git&lt;/a&gt;。&lt;/p&gt;

      &lt;p&gt;首先，创建你的 Blog 仓库 username(请确保跟你的账号名相同).github.com:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ mkdir username.github.com
        $ cd username.github.com
      &lt;/pre&gt;


      &lt;p&gt;新建一个 index.html 文件，像下面这样:&lt;/p&gt;

      &lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;&lt;span class=&quot;lineno&quot;&gt; 1&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 3&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 4&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 5&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 6&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 7&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 8&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello!&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt; 9&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;lineno&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
      &lt;/code&gt;&lt;/pre&gt;
      &lt;/div&gt;


      &lt;p&gt;初始化仓库、提交并push到Github:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ git init
        $ git add .
        $ git commit -a -m 'init commit.'
        $ git remote add origin
        $ git push origin master
      &lt;/pre&gt;


      &lt;p&gt;现在你打开 username.github.com 就可以看到刚才新建的页面了，就是这么简单。当然也可以为你的Blog仓库绑定独立域名，具体做法就是：&lt;/p&gt;

      &lt;ol&gt;
      &lt;li&gt;在你的仓库中新建内容为 www.youdomain.com 的 CNAME 文件；&lt;/li&gt;
      &lt;li&gt;在你的域名管理页或者是DNS解析的地方，增加一个记录，记录类别为CNAME(Alias)类型.&lt;/li&gt;
      &lt;/ol&gt;


      &lt;p class=&quot;note&quot;&gt;*Note：如果你在CNAME中填写的是顶级域名，就得设置DNS的记录类别为A(Host)型，并设置主机为207.97.227.245。详细介绍请移步Github的&lt;a href=&quot;http://pages.github.com&quot;&gt;Pages&lt;/a&gt;页面。&lt;/p&gt;


      &lt;p&gt;接下来我们只需要按照自己的喜好设计页面。首先认识下Jekyll的文件及目录配置:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        .
        |-- _includes
        |-- _plugins
        |-- _layout
        |   |-- default.html
        |   `-- post.html
        |-- _post
        |   |-- yyyy-mm-dd-title.markdown
        |   `-- yyyy-mm-dd-title.markdown
        |-- _site
        |-- _config.yml
        `-- index.html
      &lt;/pre&gt;


      &lt;h2&gt;_includes&lt;/h2&gt;

      &lt;p&gt;存放你需要在模板文件中包含的文件，你可以使用Liquid标签 &lt;code&gt;{&amp;permil; include file.ext &amp;permil;}&lt;/code&gt; 来引用相应的文件。&lt;/p&gt;

      &lt;h2&gt;_plugins&lt;/h2&gt;

      &lt;p&gt;可以增加你自己的插件&lt;/p&gt;

      &lt;h2&gt;_layout&lt;/h2&gt;

      &lt;p&gt;存放布局模板，请参考&lt;a href=&quot;https://github.com/taberhuang/taberhuang.github.com/tree/master/_layouts&quot;&gt;https://github.com/taberhuang/taberhuang.github.com/tree/master/_layouts&lt;/a&gt;&lt;/p&gt;

      &lt;h2&gt;_post&lt;/h2&gt;

      &lt;p&gt;存放文章列表，文件命名一定要遵循 yyyy-mm-dd-title.html|markdown|textile 规则，请参考&lt;a href=&quot;https://github.com/taberhuang/taberhuang.github.com/tree/master/_posts&quot;&gt;https://github.com/taberhuang/taberhuang.github.com/tree/master/_posts&lt;/a&gt;&lt;/p&gt;

      &lt;h2&gt;_site&lt;/h2&gt;

      &lt;p&gt;Jekyll自动生成的，所以可以忽略，如果你有在本地安装Jekyll并预览了的话，可以使用.gitignore设置Git停止对本目录的跟踪。&lt;/p&gt;

      &lt;h2&gt;_config.yml&lt;/h2&gt;

      &lt;p&gt;设置经常使用的配置选项，这样在本地启动预览时就不用每次都手动输入了。&lt;/p&gt;

      &lt;h2&gt;index.html 和所有的 HTML/Markdown/Textile 文件&lt;/h2&gt;

      &lt;p&gt;所有的HTML/Markdown/Textile文件都可以包含 YAML 配置，这类文件都会被Jekyll解析。&lt;/p&gt;

      &lt;p&gt;现在你可以在自己的仓库中配置好你自己的目录及文件，也可以clone我的仓库，然后修改。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ git clone https://github.com/taberhuang/taberhuang.github.com.git
      &lt;/pre&gt;


      &lt;p&gt;修改完后就可以push你的代码到Github上，看到结果了。刚才有说到本地预览，如果你想在本地预览后，确保没错误再push的话，就需要在本地安装Jekyll，下面介绍下Jekyll的安装方法。&lt;/p&gt;

      &lt;p&gt;一、安装Ruby运行环境和RubyGem:Windows用户只要下载 &lt;a href=&quot;http://rubyforge.org/frs/download.php/74298/rubyinstaller-1.9.2-p180.exe&quot; title=&quot;点击下载&quot;&gt;RubyInstaller&lt;/a&gt;。下载安装后请手动升级gem.&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem update --system
      &lt;/pre&gt;


      &lt;p&gt;二、安装DevKit。&lt;a href=&quot;http://cloud.github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe&quot; target=&quot;_blank&quot;&gt;下载DevKit&lt;/a&gt;,DevKit是windows平台编译和使用本地C/C++扩展包工具。用来模拟Linux平台下的 &lt;code&gt;make,gcc,sh&lt;/code&gt; 进行编译。下载文件后，解压到 `C:\DevKit'，再通过命令行安装:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ cd C:\DevKit
        $ ruby dk.rb init
        $ ruby dk.rb install
      &lt;/pre&gt;


      &lt;p&gt;三、安装并检查刚才的DevKit安装是否成功。如果成功安装，则DevKit也就安装成功，如果不成功，请重新安装DevKit。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem install jekyll
      &lt;/pre&gt;


      &lt;p&gt;四、安装Rdiscount，这个是用来解析Markdown标记的解析包。如果你使用Textile的话，就是安装Kramdown。&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        $ gem install rdiscount
      &lt;/pre&gt;


      &lt;p&gt;所有的环境和依赖包都安装成功后，进入你的仓库目录，用下面的命令便可启动Jekyll，并在本地预览了，预览地址默认为 &lt;code&gt;127.0.0.1:4000&lt;/code&gt;，当然你也可以通过 _config.yml 配置:&lt;/p&gt;

      &lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
        jekyll --server
      &lt;/pre&gt;


      &lt;p&gt;是不是很爽?&lt;/p&gt;

      &lt;div style=&quot;margin-top:20px&quot;&gt;参考及相关资料：&lt;/div&gt;


      &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;http://pages.github.com/&quot;&gt;http://pages.github.com/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/mojombo/jekyll/wiki&quot;&gt;https://github.com/mojombo/jekyll/wiki&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blog.envylabs.com/2009/08/publishing-a-blog-with-github-pages-and-jekyll/&quot;&gt;http://blog.envylabs.com/2009/08/publishing-a-blog-with-github-pages-and-jekyll/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://daringfireball.net/projects/markdown/syntax&quot;&gt;http://daringfireball.net/projects/markdown/syntax&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;

</content>
    </entry>
  
    <entry>
      <title>(转载)应用jekyll构建基于github page的博客</title>
      <link href="http://lxj.name/other/2010/09/20/saberma-github-page-blog-build-with-jekyll.html"/>
      <updated>2010-09-20T00:00:00-07:00</updated>
      <id>http://lxj.name/other/2010/09/20/saberma-github-page-blog-build-with-jekyll</id>
      <content type="html">&lt;p&gt;基于github page的博客好处:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;简单至极，且完全免费&lt;br /&gt;
可以支持rss订阅，评论功能&lt;br /&gt;
依赖于git，文章原生支持版本控制(对比)，更有利于知识库类文章&lt;br /&gt;
可以使用vim编写文章，写的时候像在写代码，更符合程序员的习惯&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;本博客此次除了启用全新个人域名saberma.me，将做以下调整&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;美化网站风格，更加的清新:)&lt;br /&gt;
页面布局调整为html5、css3架构&lt;br /&gt;
文章可按分类显示&lt;br /&gt;
代码增加高亮显示&lt;br /&gt;
增加rss feed输出&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;挑个新的博客模板&lt;/h2&gt;
&lt;p&gt;要求是基于html5、css3的免费模板，google之，发现个好地方: &lt;a href=&quot;http://freehtml5templates.com&quot;&gt;http://freehtml5templates.com&lt;/a&gt;&lt;br /&gt;
一页一页的挑吧，总会找到自己喜欢的，可以根据右下角的Tag Cloud进行筛选，现在看到本站的新样子就是找好久才看中的模板&lt;/p&gt;
&lt;h2&gt;绑定独立域名&lt;/h2&gt;
&lt;p&gt;在godaddy中注册 &lt;a href=&quot;http://saberma.em&quot;&gt;saberma.me&lt;/a&gt; 域名，.me专用于博客类型，但比.com贵一些，且没有优惠&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;注册完域名后，在域名管理中增加A record并指向207.97.227.245&lt;/li&gt;
	&lt;li&gt;在你的github项目下增加CNAME文件，内容为你的域名，如 &lt;a href=&quot;http://github.com/saberma/saberma.github.com/blob/master/CNAME&quot;&gt;http://github.com/saberma/saberma.github.com/blob/master/&lt;span class=&quot;caps&quot;&gt;CNAME&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;具体参考 &lt;a href=&quot;http://pages.github.com&quot;&gt;http://pages.github.com&lt;/a&gt; 中 &lt;code&gt;Custom Domains&lt;/code&gt; 部分的内容&lt;/p&gt;
&lt;h2&gt;pygments代码高亮&lt;/h2&gt;
&lt;h3&gt;安装pygments&lt;/h3&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# On Ubuntu 安装&lt;/span&gt;
sudo apt-get install python-pygments
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;http://wiki.github.com/mojombo/jekyll/install&quot;&gt;完整安装说明&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;生成高亮显示的css文件&lt;/h3&gt;
&lt;p&gt;选择喜欢的样式，记下名称&lt;br /&gt;
&lt;a href=&quot;http://pygments.org/demo/6622&quot;&gt;http://pygments.org/demo/6622&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;我选择的是fruity style，作为pygmentize命令style的参数值&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# 生成相应的css&lt;/span&gt;
pygmentize -S fruity -f html &amp;gt; stylesheets/syntax.css
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;http://pygments.org/docs/quickstart/&quot;&gt;参考pygments Command line usage&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;如何使用&lt;/h3&gt;
&lt;p&gt;语法高亮的代码段&lt;/p&gt;
&lt;pre&gt;
{% highlight ruby %}
def foo
  puts 'foo'
end
{% endhighlight %}
&lt;/pre&gt;
&lt;p&gt;highlight后面第一个参数为language，如php，也可以是ruby控制台irb，更多lanuages可以查询 &lt;a href=&quot;http://pygments.org/docs/lexers/&quot;&gt;http://pygments.org/docs/lexers/&lt;/a&gt;&lt;br /&gt;
第一个参数为必填，不填会导致_site目录生成不了相应的html文件，第二个参数显示行号&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://wiki.github.com/mojombo/jekyll/liquid-extensions&quot;&gt;参考jekyll说明&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Markdown标记与Liquid逻辑处理&lt;/h2&gt;
&lt;h3&gt;两个知识点&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;为避免直接编写html代码，编写文章时，内容需要加入标记信息，即Markdown&lt;/li&gt;
	&lt;li&gt;博客中都是需要经过处理的，比如逻辑判断处理、循环处理，jekyll应用liquid模板语言进行这些处理&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Markdown&lt;/h3&gt;
&lt;p&gt;标记语言有很多种，如textile&lt;br /&gt;
这些标记语言会被标记引擎转换，输出成相应的目标格式（大部分情况是输出成html）&lt;br /&gt;
引擎也有很多种，不同的编程语言有不同的实现，ruby常用的引擎有RedCloth&lt;/p&gt;
&lt;h3&gt;Liquid&lt;/h3&gt;
&lt;p&gt;简单来说，凡是看到{{}}或者{% %}包含的内容都是会被Liquid引擎处理的&lt;/p&gt;
&lt;p&gt;比如*将日期格式化*的liquid语句&lt;/p&gt;
&lt;pre&gt;
{{ post.date | date_to_string }}
&lt;/pre&gt;
&lt;p&gt;除了标记的Liquid语法外，jekyll还扩展出了几个便利的方法，其中有上面介绍的highlight方法&lt;br /&gt;
&lt;a href=&quot;http://wiki.github.com/mojombo/jekyll/liquid-extensions&quot;&gt;jekyll liquid扩展&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://github.com/tobi/liquid/wiki/Liquid-for-Designers&quot;&gt;liquid参考资料&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;整合评论&lt;/h2&gt;
&lt;p&gt;由于github page最终生成的都是静态html页面，所以是没有评论功能呢&lt;br /&gt;
但我们利用disqus实现在线评论功能，先到 &lt;a href=&quot;http://disqus.com&quot;&gt;http://disqus.com&lt;/a&gt; 注册帐号(免费)&lt;br /&gt;
注册成功后，为简单起见，只要把 &lt;code&gt;_includes/post.html&lt;/code&gt; 中的saberma替换为你的注册帐号就行了(disqus_url输入你实际的域名)&lt;/p&gt;
&lt;h2&gt;整合rss订阅&lt;/h2&gt;
&lt;p&gt;因为jekyll可以生成blogs列表，所以我们可以编写atom.xml，由jekyll生成最终xml结果&lt;br /&gt;
&lt;a href=&quot;/atom.xml&quot;&gt;这是我的atom.xml文件&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;将生成的xml地址提交至 &lt;a href=&quot;http://www.feedsky.com&quot;&gt;feedsky.com&lt;/a&gt; ，由feedsky进行管理和美化&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://elemel.se/2009/01/25/setting-up-an-atom-feed-at-github-pages.html&quot;&gt;Setting Up an Atom Feed at GitHub Pages&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;你也想弄一个github page博客?&lt;/h2&gt;
&lt;p&gt;最快的做法是 &lt;a href=&quot;http://github.com/saberma/saberma.github.com&quot;&gt;fork我的博客&lt;/a&gt; ，git clone到你的电脑&lt;br /&gt;
然后修改成你的，具体需要调整的地方是:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;删除_posts中的文章&lt;/li&gt;
	&lt;li&gt;按上面介绍的[整合评论]修改 &lt;code&gt;_includes/post.htm&lt;/code&gt; 文件&lt;/li&gt;
	&lt;li&gt;按上面介绍的[整合rss]修改 &lt;code&gt;atom.xml&lt;/code&gt; 文件&lt;/li&gt;
	&lt;li&gt;修改CNAME的内容为你的独立域名&lt;/li&gt;
	&lt;li&gt;运行jekyll，看看效果&lt;/li&gt;
	&lt;li&gt;上传!ok，访问你的blog地址看看&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;参考资源&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.envylabs.com/2009/08/publishing-a-blog-with-github-pages-and-jekyll/&quot;&gt;publishing-a-blog-with-github-pages-and-jekyll&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://github.com/mojombo/jekyll/wiki&quot;&gt;jekyll wiki&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://pages.github.com&quot;&gt;http://pages.github.com&lt;/a&gt;&lt;/p&gt;</content>
    </entry>
  
    <entry>
      <title>Jekyll 的一些函数和技巧</title>
      <link href="http://lxj.name/other/2010/03/06/Jekyl-some-of-the-functions-and-techniques.html"/>
      <updated>2010-03-06T00:00:00-08:00</updated>
      <id>http://lxj.name/other/2010/03/06/Jekyl-some-of-the-functions-and-techniques</id>
      <content type="html">&lt;p class=&quot;description&quot;&gt;在使用 Jekyll 构建博客的过程中，我记录下了这些常见的函数，例如循环输出文章，输出分页等&lt;/p&gt;
&lt;h2&gt;一些函数&lt;/h2&gt;

&lt;p&gt;循环输出 3 篇文章&lt;/p&gt;

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
for post in site.posts limit:3
endfor
&lt;/pre&gt;


&lt;p&gt;循环输出最近 3 篇&lt;/p&gt;

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
for post in site.posts offset:3 limit:3
endfor
&lt;/pre&gt;


&lt;p&gt;日期&lt;/p&gt;

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
page.date | date:&quot;%B %b, %Y&quot;
&lt;/pre&gt;


&lt;p&gt;分页输出&lt;/p&gt;

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
for post in paginator.posts
  content
endfor
&lt;/pre&gt;
   

&lt;p&gt;分页&lt;/p&gt; 

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
if paginator.previous_page
  //判断输出前一个分页
  //&quot;page&quot; + paginator.previous_page
endif
if paginator.next_page
  //判断输出后一个分页
  //&quot;page&quot; + paginator.next_page
endif
for page in (1..paginator.total_pages)
  if page == paginator.page
     //如果是当前分页
     //page
  else
     //不是的话输出其他分页链接号码
     //&quot;page&quot; + page
  endif
endfor
&lt;/pre&gt;


&lt;p&gt;文章页面显示前一篇文章和后一篇文章&lt;/p&gt;

&lt;pre title=&quot;code&quot; class=&quot;brush: plain;&quot;&gt;
if page.previous
  //url:    page.previous.url
  //title:  page.previous.title | truncatewords:5
endif
if page.next
  //url:    page.next.url
  //title:  page.next.url | truncatewords:5
&lt;/pre&gt;</content>
    </entry>
  
</feed>

