Octopress Sheet
Table of Contents
New post
rake new_post["title"] # use bash
you can add published: false
to prevent it from being posted when you
generate your
You can add a single category or multiple categories like this.
# One category categories: Sass # Multiple categories example 1 categories: [CSS3, Sass, Media Queries] # Multiple categories example 2 categories: - CSS3 - Sass - Media Queries 1
New Pages1
rake new_page[About] emacs source/_includes/custom/navigation.html add <li><a href="{{ root_url }}/my-wiki">My Wiki</a></li>
Content
<!-- more -->
add a published: false
to your post’s YAML header. You can preview
these posts with rake preview on your local server, but they won’t get
published by rake generate
.
Warning and Info style
<p class="info">info</p> <p class="warning">warning</p>
Generate & Preview
rake generate
## Generating Site with Jekyll unchanged sass/screen.scss Configuration from /home/Blog/octopress/_config.yml Building site: source -> public Successfully generated site: source -> public
rake watch
Watches source/ and sass/ for changes and regenerates
rake preview
http://localhost:4000
rake deploy
## Deploying branch to Github Pages rm -rf _deploy/sitemap.xml rm -rf _deploy/favicon.png rm -rf _deploy/atom.xml rm -rf _deploy/javascripts rm -rf _deploy/index.html rm -rf _deploy/assets rm -rf _deploy/images rm -rf _deploy/org_posts rm -rf _deploy/blog rm -rf _deploy/stylesheets ## copying public to _deploy cp -r public/. _deploy cd _deploy ## Commiting: Site updated at 2012-07-28 14:59:42 UTC [master 19b8fe9] Site updated at 2012-07-28 14:59:42 UTC 8 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 CNAME ## Pushing generated _deploy website Counting objects: 39, done. Delta compression using up to 8 threads. Compressing objects: 100% (12/12), done. Writing objects: 100% (21/21), 2.53 KiB, done. Total 21 (delta 8), reused 0 (delta 0) To git@github.com:shishougang/shishougang.github.com.git 9407c79..19b8fe9 master -> master ## Github Pages deploy complete cd -
preview one post for accelerating
rake isolate [some-post] #only leave the "some-post" in the "source/_post", the others are in #"source/_stash" rake integrate #move the files in "source/stash" back to "_post" rake generate
Image folder
source/static

clone the octopress site to the local
git clone -b source git@github.com:username/username.github.com.git octopress #get the "source" branch to the local folder "octopress" cd octopress git clone git@github.com:username/username.github.com.git _deploy #get the site content from the "master" branch to the local folder _deploy in the octopress rake install #Install the octopress theme rake setup_github_pages
update the files from the github
cd local_octopress_directory git pull origin source cd ./_deploy git pull origin master
the local_octopress directory=> remote source branch
the _deploy directory=> remote master branch
Sharing Code Snippets2
Backtick Code Blocks
Syntax
``` [language] [title] [url] [link text] code snippet ```
Gist Embedding
Syntax
{% gist gist_id [filename] %}
If you have a gist with multiple files, you can include files one at a time by adding the name after the gist id.
{% gist 1059334 svg_bullets.rb %} {% gist 1059334 usage.scss %}
Include Code Snippets
In the _config.yml
you can set your code_dir
but the default is
source/downloads/code
. Simply put a file anywhere under that directory
and use the following tag to embed it in a post.
Syntax
{% include_code [title] [lang:language] path/to/file %}
Example 1
This includes a file from source/downloads/code/test.js
.
{% include_code test.js %}
Example 2
By default the <figcaption>
will be the filename, but you can add a
title before the filepath if you like.
This includes a file from source/downloads/code/ruby/test.rb
.
{% include_code Add to_fraction for floats ruby/test.rb %}
The name becomes Add to_fraction for floats (test.rb)
.
Example 3(Force Highlighting)
Add lang:your_language
to force highlighting if the filename doesn’t
work.
{% include_code test.coffee lang:coffeescript %}
Inline Code Blocks
Syntax
{% codeblock [title] [lang:language] [url] [link text] %} code snippet {% endcodeblock %}
Example 1
{% codeblock %} Awesome code snippet {% endcodeblock %}
Example 2
{% codeblock lang:objc %} [rectangle setX: 10 y: 10 width: 20 height: 20]; {% endcodeblock %}
Example 3
{% codeblock Time to be Awesome - awesome.rb %}
puts "Awesome!" unless lame
{% endcodeblock %}
The tile becomes =Time to be Awesome - awesome.rb =.
Example 4(Force Highlighting)
{% codeblock Here's an example .rvmrc file. lang:ruby %} rvm ruby-1.8.6 # ZOMG, seriously? We still use this version? {% endcodeblock %}
Example 5
{% codeblock Javascript Array Syntax lang:js http://j.mp/pPUUmW MDN Documentation %} var arr1 = new Array(arrayLength); var arr2 = new Array(element0, element1, ..., elementN); {% endcodeblock %}
Plugins3
HTML5 Video Tag
Syntax
{% video url/to/video [width height] [url/to/poster] %}
Example
{% video http://s3.imathis.com/video/zero-to-fancy-buttons.mp4 640 320 http://s3.imathis.com/video/zero-to-fancy-buttons.png %}
Image Tag
Syntax
{% img [class names] /path/to/image [width] [height] [title text [alt text]] %}
Examples
{% img http://placekitten.com/890/280 %} {% img left http://placekitten.com/320/250 Place Kitten #2 %} {% img right http://placekitten.com/300/500 150 250 Place Kitten #3 %} {% img right http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}
Block quote
Syntax
{% blockquote [author[, source]] [link] [source_link_title] %} Quote string {% endblockquote %}
Example
- plain
{% blockquote %} Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling. {% endblockquote %}
- Quote from a printed work.
{% blockquote Douglas Adams, The Hichhikers Guide to the Galaxy %} Flying is learning how to throw yourself at the ground and miss. {% endblockquote %}
- Quote from Twitter
{% blockquote @allanbranch https://twitter.com/allanbranch/status/90766146063712256 %}
Over the past 24 hours I've been reflecting on my life & I've realized only one thing. I need a medieval battle axe.
{% endblockquote %}
- Quote from an article on the web
{% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} Every interaction is both precious and an opportunity to delight. {% endblockquote %}
Pull quote
Syntax
{% pullquote %} Surround your paragraph with the pull quote tags. Then when you come to the text you want to pull, {" surround it like this "} and that's all there is to it. {% endpullquote %}
Render Partial
Syntax
{% render_partial path/to/file %}
The render_partial
tag resolves paths to the source
directory, so
write your paths accordingly.
- Example Usage 1
Perhaps you want to create a readme page for your blog. You have a file at source/readme/index.markdown and the README.markdown for your project is a sibling to your source directory. To import your project’s readme into your readme page, you’d do this:
{% render_partial ../README.markdown %}
- Example Usage 2
You may have two pages which need to share some of the same content. To prevent your partial from being rendered by Jekyll as a page, add an underscore to the beginning of the file name, or put it in a directory that begins with an underscore. For example, if you wanted multiple pages to share a table of contents, you might create source/documentation/partials/TOC.markdown. Any post or page could import this file like this:
{% render_partial documentation/TOC.markdown %}
pygments Supported languages4
Programming languages
ActionScript
Ada
ANTLR
AppleScript
Assembly (various)
Asymptote
Awk
Befunge
Boo
BrainFuck
C, C++
C#
Clojure
CoffeeScript
ColdFusion
Common Lisp
Coq
Cython
D
Dart
Delphi
Dylan
Erlang
Factor
Fancy
Fortran
F#
Gherkin (Cucumber)
GL shaders
Groovy
Haskell (incl. Literate Haskell)
Io
Java
JavaScript
LLVM
Logtalk
Lua
Matlab
MiniD
Modelica
Modula-2
MuPad
Nemerle
Nimrod
Objective-C
Objective-J
Octave
OCaml
PHP
Perl
PovRay
PostScript
PowerShell
Prolog
Python 2.x and 3.x (incl. console sessions and tracebacks)
Rebol
Redcode
Ruby (incl. irb sessions)
S, S-Plus, R
Scala
Scheme
Scilab
Smalltalk
SNOBOL
Tcl
Vala
Verilog
VHDL
Visual Basic.NET
XQuery
Template languages
Cheetah templates
Django/Jinja templates
ERB (Ruby templating)
Genshi (the Trac template language)
JSP (Java Server Pages)
Myghty (the HTML::Mason based framework)
Mako (the Myghty successor)
Smarty templates (PHP templating)
Tea
Other markup
Apache config files
Bash shell scripts
BBCode
CMake
CSS
Debian control files
Diff files
DTD
Gettext catalogs
Gnuplot script
Groff markup
HTML
HTTP sessions
INI-style config files
IRC logs (irssi style)
Lighttpd config files
Makefiles
MoinMoin/Trac Wiki markup
MySQL
Nginx config files
POV-Ray scenes
Ragel
Redcode
ReST
SQL, also MySQL, SQLite
Squid configuration
TeX
tcsh
Vim Script
Windows batch files
XML
XSLT
YAML
References and Footnotes
kramdown
support footnotes
Blah blah blah.[^fn] Lorem ipsum...
[^fn]: Here's a footnote!
Table Style
左对齐表头 | 中间对齐表头 | 右对齐表头| :----------|:------------:|----------:| 左对齐数据 |中间对齐数据 |右对齐数据|
kramdown support more5
After installing system
Install RVM
curl -L https://get.rvm.io | bash -s stable --ruby
Install Ruby 1.9.3
rvm install 1.9.3 rvm use 1.9.3 rvm rubygems latest rvm use --default 1.9.3 ruby --version
Install dependencies
gem install bundler bundle instal
Advanced Tweaks & Tips
- Tips & Tricks for Migrating From WordPress to Octopress
- Improve Octopress with Advanced Tweaks & Tips
- Adding Related Post to Octopress
- Sidebar category list
- Add a List of Popular Posts
- Display special characters in markdown on Octopress
- Custom 404 Page
- Improving the relatedposts feature of jekyll
- Auto-deploying to my Octopress blog with Travis-CI
- Org-Mode Octopress Setup V2
- use Org-octopress package
- Gorgeous Octopress Codeblocks with CodeRay