install
https://github.com/imathis/octopress
git clone https://github.com/imathis/octopress
bundle install
rake install
開新的repo,名稱打上 username.github.io
rake setup_github_pages
輸入: git@github.com:username/username.github.io.git
rake generate
rake deploy
=> rake gen_deploy
git add .
git commit -am "ok"
git push origin source
! [rejected] master -> master (non-fast-forward)
cd _deploy
git pull origin master
cd ..
rake deploy
Custom Domains
echo 'your-domain.com' >> source/CNAME
rake preview
1
2
3
4
5
| #Rakefile
#28
server_port = "80"
#86
rackupPid = Process.spawn("rackup -o 0.0.0.0 --port #{server_port}")
|
debug
jekyll serve --trace
jekyll 2.5.3 | Error: user bg.UAS doesn’t exist
rm source/images/~bg.UAS
command
產生文章
rake new_page["about"]
rake new_post["title"]
rake generate preview
rake gen_deply
上傳
git add .
git commit -am "`date +%Y-%m-%d:%H:%M:%S`"
git push origin source
bundle exec rake gen_deploy
下載
git clone -b source git@github.com:username/username.github.io.git octopress
cd octopress
git clone git@github.com:username/username.github.io.git _deploy
git pull origin source
cd ./_deploy
git pull origin master
homepage
1
2
3
4
5
6
7
| #source/_includes/custom/navigation.html
<ul class="main-navigation">
<li><a href="{{ root_url }}/">Home</a></li>
<li><a href="{{ root_url }}/recent">Recent</a></li>
<li><a href="{{ root_url }}/blog/archives">Archives</a></li>
<li><a href="{{ root_url }}/blog/categories">Categories</a></li>
</ul>
|
1
2
3
| #Rakefile
#21
blog_index_dir = 'source/blog'
|
mkdir source/recent
mv source/index.html source/recent/
#source/recent/index.html
#7
{% for post in site.posts limit: site.recent_posts %}
rake new_page["index.html"]
Category
ref http://codemacro.com/2012/07/18/add-category-list-to-octopress/
ref https://github.com/shunnien/octopress-category-list
code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| #plugins/category_list_tag.rb
module Jekyll
class CategoryList < Liquid::Tag
def render(context)
html = ""
categories = context.registers[:site].categories.keys
categories.sort.each do |category|
posts_in_category = context.registers[:site].categories[category].size
category_dir = context.registers[:site].config['category_dir']
category_url = File.join(category_dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase)
html << "<li class='category'><a href='/#{category_url}/'>#{category} (#{posts_in_category})</a></li>\n"
end
html
end
end
class CategoryListTop < Liquid::Tag
def render(context)
html = ""
categories = context.registers[:site].categories.keys
categories.sort.each do |category|
category_dir = context.registers[:site].config['category_dir']
category_url = File.join(category_dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase)
html << "<h2 class='entry-title'><a href='/#{category_url}/'>#{category}</a></h2>"
end
html
end
end
end
Liquid::Template.register_tag('category_list_top', Jekyll::CategoryListTop)
Liquid::Template.register_tag('category_list', Jekyll::CategoryList)
|
asides
1
2
3
4
5
6
7
| #source/_includes/asides/category_list.html
<section>
<h1>Categories</h1>
<ul id="categories">
{% category_list %}
</ul>
</section>
|
在側邊加入連結
1
2
3
| #_config.yml
#56
default_asides: [asides/category_list.html]
|
top
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| #source/blog/categories/index.html
---
layout: page
title: Categories
footer: false
---
<style>
a {
text-decoration:none;
}
</style>
<article>
{% category_list_top %}
</article>
|
在上方加入連結
1
2
3
4
| #source/_includes/custom/navigation.html
<ul class="main-navigation">
<li><a href="{{ root_url }}/blog/categories">Categories</a></li>
</ul>
|
Background image in header
ref https://github.com/imathis/octopress/issues/356
1
2
3
4
5
| #sass/custom/_styles.scss
header[role="banner"] {
background-image: url(/images/bg.png);
background-repeat: no-repeat;
}
|
新產生的文章給予 uncategorized
1
2
3
| #Rackfile
#117
post.puts "categories: uncategorized"
|
貼語法語法
ref http://blog.slaks.net/2013-06-10/jekyll-endraw-in-code/
若要顯示 {% category_list_top %}
{% raw %}{% category_list_top %}{% endraw %}
若要顯示 {% raw %}{% endraw %}
{% assign oTag = '{%' %}
# 然後在貼下半部
{{ oTag }}raw %}{% endraw %}
{{ oTag }}endraw %}{% endraw %}
若要顯示 ` 前後用兩個 ` 包起來
``git commit -am "`date +%Y-%m-%d:%H:%M:%S`"``
圖片

連結
[Google](https://www.google.com.tw/)