尝试 Jekyll 博客

来源:互联网 发布:海城市教育局网通知 编辑:程序博客网 时间:2024/06/05 16:30
转自:点击打开链接
微博上听大侠说起博客, 想起来我的博客贴代码和很麻烦
处理代码铁定不会自己学起来了, 现成应该有, 比如 Markdown 闻名已久
而且发现 Jekyll 正好也 Markdown, Ruby 我至少能认出来, 打算尝试
想起另外有个 Octopress 基于 Jekyll 定制, 于是看了下
http://blog.xdite.net/posts/2011/10/07/what-is-octopress/
http://blog.yxwang.me/2011/11/migrated-to-octopress/
http://lianxu.me/blog/2011/12/21/integrate-instagram-into-octopress/
大概说 Octopress 功能更丰富, 虽然配置比较烦
而 Jekyll 比较基础, 界面简单, 可能还自己定制
所以我还是选 Jekyll 了, 比较我想自己做网页不是一天两天
看下面的博客了解下大概的配置, 虽然知道是基于 Ruby 的静态博客
http://osser.me/git/2011/11/08/github-page.html
http://code.raycn.net/tech/github.html
http://www.yangzhiping.com/tech/wordpress-to-jekyll.html
http://roylez.heroku.com/2010/02/04/jekyll-on-heroku.html
http://www.worldhello.net/gotgithub/03-project-hosting/050-homepage.html
大概 Gem 安装, 本地写博客, 然后编译 Markdown 到 HTML 上传
似乎可以装 Heroku, 但那儿有免费内存限制, 还是 Github
然后看官网, 大量已有的博客, 看不出门道 - -!!
https://github.com/mojombo/jekyll/wiki/Sites
看了官网, 发现主要讲配置, 黑客... 我还是按博客配置吧

gem 因为国外, 先去看@李华顺 大侠的镜像逛一圈
http://ruby.taobao.org/
$ gem sources -a http://ruby.taobao.org/ 先抄命令添加

但近一个小时还是这个问题, 排除了 repo 的问题了, 应该是 Ruby 版本
$ gem install jekyll
ERROR:  While executing gem ... (TypeError)
    instance of Date needs to have method `marshal_load'
Ubuntu 的 Ruby 被限制的, 下面是 Ubuntu 上说的, 没提到这个问题
https://help.ubuntu.com/community/RubyOnRails
尝试了俺这个重装了 Ruby1.8 , 问题依旧
http://programblings.com/2008/11/04/installing-gems-with-command-line-interfaces-on-ubuntu-810/
然后去尝试 RVM, 安装方法如下, 但是需要手动设置终端执行的命令
http://beginrescueend.com/rvm/install/
https://rvm.beginrescueend.com/workflow/screen/
我用比较直接的从 ~/.bashrc 绑定命令了, 不过安装过程都要权限, 这个用不上
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
alias rvm='/usr/share/ruby-rvm/bin/rvm'
关于安装, 官网可以参考的命令, 再找一下 gem 的
http://beginrescueend.com/rvm/install/
居然 RVM 老要求我 root 权限, 搜索后发现安装错了, 清除配置从头再来

$ sudo apt-get --purge remove ruby-rvm
http://stackoverflow.com/questions/8402827/installing-rvm-on-ubuntu
清除配置重新安装就不用 sudo 了, 并在 ~/.bashrc 自动创建了配置

$ rvm install 1.8.7
直到安装完成, 发现 ruby 命令古怪, 翻到下面这份教程
http://techiferous.com/2010/02/installing-rails-3-beta-with-rvm-and-ruby-1-8-7/
的确, 原来的问题是照旧, 但是发现有一个很早的解决方案
http://www.pervasivecode.com/blog/2010/03/16/using-rvm-to-install-ree-1-8-7-2009-10/
结果还是不行... 只好就这样发贴了..
http://ruby-china.org/topics/636

最后用 RVM 的 Ruby 1.9.2 终于安装成功了
$ rvm install 1.9.2
初次运行 $ jekyll --server 只是生成了 _site 目录运行 4000 端口
, 很怪
按博文和报错就是要先学会配置这个文件 _config.yml
(误导.. 没必要的)官网有默认配置和可选的表格, 我先抄一份到 _config.yml 文件
https://github.com/mojombo/jekyll/wiki/Configuration
(这里误导...)看设定的文件结构有个 index.html , 于是建立一个, 成功
搜到英文的教程看了下, 原来都是 Rails 做网站模版的知识, 我不行了..
http://www.ksornberger.com/blog/blogging-with-jekyll-and-github/
http://alexyoung.org/2009/07/09/new-blog/
http://developmentseed.org/blog/2011/09/09/jekyll-github-pages/
http://www.quirkey.com/blog/2009/05/01/github-pages-for-fun-and-win/
http://webcache.googleusercontent.com/search?q=cache:IGyfgFXeuZsJ:philipm.at/2011/0507/+&cd=18&hl=en&ct=clnk
http://klepas.org/jekyll-a-static-site-generator/
下面这分算是教程了, 是一篇译文, 不过我感觉还是太难了
http://chen.yanping.me/cn/blog/2011/12/15/building-static-sites-with-jekyll/

然后看下 Octopress 配置看去果然简单很多
http://huanggang.me/archives/654
http://octopress.org/docs/deploying/github/
有了之前 gem 的经验, 搜到 $ bundle install 出错可以改源
http://www.renren.it/a/bianchengyuyan/Ruby/20111109/105659.html
按着教程上几个命令居然直接完成了(而且因为 git 早在用的缘故)
后面学下 Markdown 和 Rails 来改变细节
http://octopress.org/docs/configuring/

深夜了回头看后面上面提过的 3 篇文章, 终于理处头绪
http://www.ksornberger.com/blog/blogging-with-jekyll-and-github/
http://chen.yanping.me/cn/blog/2011/12/15/building-static-sites-with-jekyll/
http://osser.me/git/2011/11/08/github-page.html
首先 _layouts/default.html 是主角, 每个页面都以他为主要模版
然后在 index.html 和 _layouts/post.html 都会将其包含进来
而 _post/2011-12-30-for-example.md 则会讲 _layouts/post.html 包含进来
include 功能类似, 但 include 似乎不能有 {{content}} 之类(?)
就是说被包含的是模版共用的部分, 比如网站顶部的导航
而花括号包围的语句目的就是将调用信息传给共用的模版
我就此试验, 发现成功, 于是思路就清晰了, CSS 等目录也清楚了

至于具体怎样传到 Github, 白天再看了

然后下面两篇提到标签功能, category(s) 和 tags, 比如 tags
在 _posts/2011-12-10-title.md 加上 "tags: blog"(具体参照链接)
然后 index.html 中 for/in 访问 site.tags.blog 得到对应 post

不过具体我没弄清, 试验上面方法是可行的
http://orgmode.org/worg/org-tutorials/org-jekyll.html
http://developmentseed.org/blog/2011/09/09/jekyll-github-pages/
再看看其他寻找细节, 都语焉不详, 不过漂亮的倒不少
http://www.testically.org/2011/11/09/github-pages-how-to-do-a-simple-in-page-anchor-navigation-with-jekyll-and-liquid/
http://paulstamatiou.com/how-to-wordpress-to-jekyll
这里有个 fork 版本用上了 haml, 尝试发现改动比较大, 割爱了
https://github.com/henrik/henrik.nyh.se
日期的格式在下面两个提到, 我用了 %y-%m-%d 对应 11-12-30
http://stackoverflow.com/questions/7395520/jekyll-date-format
http://orgmode.org/worg/org-tutorials/org-jekyll.html
RSS 订阅的话是 atom.xml 文件, 随便可以抄来改, 估计(?)
关于 RSS 以及代码高亮下面有讲, 我暂时不去折腾了
http://saberma.me/other/2010/09/20/saberma-github-page-blog-build-with-jekyll.html

关于 catrgoryies 和 tags 我去 StackOverflow 问了, 似乎只有 URL 的区别
http://stackoverflow.com/questions/8675841/whats-the-difference-between-categories-and-tags-in-jekyll

后面没再用 Jekyll, Markdown 和 Textile 一个对换行一个对代码不好.. 又不能撮合..
试了点点, 算简单的, 我这水平还是合适点点, 然后标签功能是支持的
http://doc.diandian.com/
点点还不清楚具体什么时候会支持 tab, 不然一直用
如果不行, 寒假尝试自己写文本转化, 反正我只要求平文本加缩进
0 0