octopress作為一個blog框架,提供了不少的個性化東東,方便大家根據(jù)自己的需求對blog做個性化,大部分都可以通過修改根目錄下的 _config.yml搞定。這個配置文件本身的語法是YAML,關于YAML語言本身,有興趣的可以看看這篇介紹文章。
回到_config.yml本身,打開后發(fā)現(xiàn)內(nèi)容就是key: value形式。這兒修改時,需要注意冒號和value之前必須有空格,否則在rake generate時,會報下面的解析錯誤:
1
2
3
4
5
6
7
8
9
10
11
| ## Generating Site with Jekyll
unchanged sass/screen.scss
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 7 column 0 (Psych::SyntaxError)
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:106:in `load'
from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:205:in `load_file'
from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/jekyll-0.11.0/lib/jekyll.rb:119:in `configuration'
from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/jekyll-0.11.0/bin/jekyll:207:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/jekyll:19:in `load'
from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/jekyll:19:in `<main>'
|
大部分配置項都可以從字面上看出什么意思,有些也有注釋,這兒挑些說下。配置文件分為三個部分:
Main Configs
1
2
3
4
5
6
| url: http://yoursite.com # blog地址
title: My Octopress Blog # blog名稱,會出現(xiàn)在左上角
subtitle: A blogging framework # title下面的副標題,可以用來放你的喜歡的名人名言,或者簡單介紹下自己
author: Your Name # 會出現(xiàn)在每篇文章下面的Posted by
simple_search: http://google.com/search # 右邊搜索框使用的搜索引擎
description: # head.html中meta name="description"的默認content,但一般都被會截斷的文章內(nèi)容替換掉
|
Jekyll & Plugins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| root: / # 網(wǎng)站的根目錄,如果你網(wǎng)站是http:///project這樣的形式,就要寫成 root: /project
# 生成文章的url形式,比如不喜歡url中帶時間,習慣后綴加html,可以寫成 /blog/:title.html
permalink: /blog/:year/:month/:day/:title/
paginate: 10 # 每頁展現(xiàn)blog的數(shù)量,如果blog數(shù)量大于這個,會產(chǎn)生翻頁
recent_posts: 5 # 右側(cè)最近發(fā)表模塊里blog的數(shù)量
# 在某篇blog中使用<!-- more -->,列表頁就不會展現(xiàn)該blog全文,就會顯示這個read on鏈接,指向blog全文
excerpt_link: "Read on →"
# 右側(cè)邊欄的展現(xiàn),有些要下面的設置配合,比如你沒有配置github_user,則這兒也不會展現(xiàn)github.html
# 也可以增加一些自己的頁面,比如在/source/_includes/custom/asides/下增加about.html
# 然后在列表中增加custom/asides/about.html即可,這兒前后的順序,就代表了頁面上下的次序
default_asides: [asides/recent_posts.html, asides/github.html, asides/twitter.html]
# 可以給不同的頁面配置不同的側(cè)邊欄
blog_index_asides:
post_asides:
page_asides:
|
3rd Party Settings
第三方的設置,在這不一一說了,一般都是填對應的用戶名即可。支持的有:github、twitter、google +1、pinbord、disqus、Google Analytics等。disqus作為評論插件,google analytics作為網(wǎng)站分析工具,強烈建議填上。沒有賬號的可以點擊鏈接去申請。至于sina微博,直接在頁面嵌入他家的iframe就行了,效果如右側(cè)所示
其他配置
- 通過修改octopress/sass/custom/_layout.scss中
$indented-lists: true
可以讓文章中列表和每行對齊,展現(xiàn)效果就如本文中列表
- 在source目錄下增加robots.txt,允許或者禁止搜索引擎抓取
- 在source增加404.html,給出更友好的出錯提示,一個簡單的獲取所有文章的404頁面代碼如下:
(404.html) download
1
2
3
4
5
6
7
8
9
10
11
12
13
| ---
layout: page
title: 抱歉,你要訪問的網(wǎng)頁不存在
footer: false
---
<h3> 看看下面有木有你要找的東東?</h3>
<div id="blog-archives">
{% for post in site.posts limit: 10 %}
<article>
{% include archive_post.html %}
</article>
{% endfor %}
</div>
|