小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

octopress的個性化配置

 思考的軌跡 2012-02-16

octopress的個性化配置

| Comments

octopress作為一個blog框架,提供了不少的個性化東東,方便大家根據(jù)自己的需求對blog做個性化,大部分都可以通過修改根目錄下的 _config.yml搞定。這個配置文件本身的語法是YAML,關(guān)于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下面的副標(biāo)題,可以用來放你的喜歡的名人名言,或者簡單介紹下自己
author: Your Name # 會出現(xiàn)在每篇文章下面的Posted by 
simple_search: http://google.com/search # 右邊搜索框使用的搜索引擎
description: # head.html中meta name="description"的默認(rèn)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中帶時間,習(xí)慣后綴加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 &rarr;"
# 右側(cè)邊欄的展現(xiàn),有些要下面的設(shè)置配合,比如你沒有配置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

第三方的設(shè)置,在這不一一說了,一般都是填對應(yīng)的用戶名即可。支持的有: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>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多