Merge branch 'master' of git@github.com:pjhyett/jekyll

This commit is contained in:
PJ Hyett 2008-12-14 18:41:00 -08:00
commit 6502f865a6
5 changed files with 216 additions and 34 deletions

View File

@ -1,3 +1,7 @@
== 0.2.0 / 2008-12-14
* Major Changes
* related_posts is now found in site.related_posts
== 0.1.6 / 2008-12-13
* Major Features
* Include files in _includes with {% include x.textile %}

View File

@ -1,46 +1,102 @@
h1. Jekyll
Jekyll is a simple, blog aware, static site generator. It takes a template directory (representing the raw form of a website), runs it through Textile and Liquid converters, and spits out a complete, static website suitable for serving with Apache or your favorite web server. Visit "http://tom.preston-werner.com":http://tom.preston-werner.com to see an example of a Jekyll generated blog.
Jekyll is a simple, blog aware, static site generator. It takes a template
directory (representing the raw form of a website), runs it through Textile or
Markdown and Liquid converters, and spits out a complete, static website
suitable for serving with Apache or your favorite web server. Visit
"http://tom.preston-werner.com":http://tom.preston-werner.com to see an
example of a Jekyll generated blog.
To understand how this all works, open up my "TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be referencing the code there.
To understand how this all works, open up my
"TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be
referencing the code there.
Take a look at "index.html":http://github.com/mojombo/tpw/tree/master/index.html. This file represents the homepage of the site. At the top of the file is a chunk of YAML that contains metadata about the file. This data tells Jekyll what layout to give the file, what the page's title should be, etc. In this case, I specify that the "default" template should be used. You can find the layout files in the "_layouts":http://github.com/mojombo/tpw/tree/master/_layouts directory. If you open "default.html":http://github.com/mojombo/tpw/tree/master/_layouts/default.html you can see that the homepage is constructed by wrapping index.html with this layout.
Take a look at
"index.html":http://github.com/mojombo/tpw/tree/master/index.html. This file
represents the homepage of the site. At the top of the file is a chunk of YAML
that contains metadata about the file. This data tells Jekyll what layout to
give the file, what the page's title should be, etc. In this case, I specify
that the "default" template should be used. You can find the layout files in
the "_layouts":http://github.com/mojombo/tpw/tree/master/_layouts directory.
If you open
"default.html":http://github.com/mojombo/tpw/tree/master/_layouts/default.html
you can see that the homepage is constructed by wrapping index.html with this
layout.
You'll also notice Liquid templating code in these files. "Liquid":http://www.liquidmarkup.org/ is a simple, extensible templating language that makes it easy to embed data in your templates. For my homepage I wanted to have a list of all my blog posts. Jekyll hands me a Hash containing various data about my site. A reverse chronological list of all my blog posts can be found in <code>site.posts</code>. Each post, in turn, contains various fields such as <code>title</code> and <code>date</code>.
You'll also notice Liquid templating code in these files.
"Liquid":http://www.liquidmarkup.org/ is a simple, extensible templating
language that makes it easy to embed data in your templates. For my homepage I
wanted to have a list of all my blog posts. Jekyll hands me a Hash containing
various data about my site. A reverse chronological list of all my blog posts
can be found in <code>site.posts</code>. Each post, in turn, contains various
fields such as <code>title</code> and <code>date</code>.
Jekyll gets the list of blog posts by parsing the files in the "_posts":http://github.com/mojombo/tpw/tree/master/_posts directory. Each post's filename contains the publishing date and slug (what shows up in the URL) that the final HTML file should have. Open up the file corresponding to a blog post: "2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile. GitHub renders textile files by default, so to better understand the file, click on the "raw":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile?raw=true view to see the original file. Here I've specified the <code>post</code> layout. If you look at that file you'll see an example of a nested layout. Layouts can contain other layouts allowing you a great deal of flexibility in how pages are assembled. In my case I use a nested layout in order to show related posts for each blog entry. The YAML also specifies the post's title which is then embedded in the post's body via Liquid.
Jekyll gets the list of blog posts by parsing the files in the
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory. Each
post's filename contains the publishing date and slug (what shows up in the
URL) that the final HTML file should have. Open up the file corresponding to a
blog post:
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
GitHub renders textile files by default, so to better understand the file,
click on the
"raw":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile?raw=true
view to see the original file. Here I've specified the <code>post</code>
layout. If you look at that file you'll see an example of a nested layout.
Layouts can contain other layouts allowing you a great deal of flexibility in
how pages are assembled. In my case I use a nested layout in order to show
related posts for each blog entry. The YAML also specifies the post's title
which is then embedded in the post's body via Liquid.
Posts are handled in a special way by Jekyll. The date you specify in the filename is used to construct the URL in the generated site. The example post, for instance, ends up at <code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
Posts are handled in a special way by Jekyll. The date you specify in the
filename is used to construct the URL in the generated site. The example post,
for instance, ends up at
<code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
Files that do not reside in directories prefixed with an underscore are mirrored into a corresponding directory structure in the generated site. If a file does not have a YAML preface, it is not run through the Liquid interpreter. Binary files are copied over unmodified.
Files that do not reside in directories prefixed with an underscore are
mirrored into a corresponding directory structure in the generated site. If a
file does not have a YAML preface, it is not run through the Liquid
interpreter. Binary files are copied over unmodified.
In order to convert your raw site into the finished version, you simply run:
<pre class="terminal"><code>$ jekyll /path/to/raw/site /path/to/place/generated/site</code></pre>
Jekyll is still a very young project. I've only developed the exact functionality that I've needed. As time goes on I'd like to see the project mature and support additional features. If you end up using Jekyll for your own blog, drop me a line and let me know what you'd like to see in future versions. Better yet, fork the project over at GitHub and hack in the features yourself!
Jekyll is still a very young project. I've only developed the exact
functionality that I've needed. As time goes on I'd like to see the project
mature and support additional features. If you end up using Jekyll for your
own blog, drop me a line and let me know what you'd like to see in future
versions. Better yet, fork the project over at GitHub and hack in the features
yourself!
h2. Example Proto-Site
My own personal site/blog is generated with Jekyll.
The proto-site repo ("http://github.com/mojombo/tpw":http://github.com/mojombo/tpw)
is converted into the actual site ("http://tom.preston-werner.com/":http://tom.preston-werner.com)
The proto-site repo
("http://github.com/mojombo/tpw":http://github.com/mojombo/tpw) is converted
into the actual site
("http://tom.preston-werner.com/":http://tom.preston-werner.com)
h2. Install
The best way to install Jekyll is via RubyGems:
$ sudo gem install jekyll
$ sudo gem install mojombo-jekyll -s http://gems.github.com/
h2. Run
$ cd /path/to/proto/site
$ jekyll
This will generate the site and place it in /path/to/proto/site/_site.
This will generate the site and place it in /path/to/proto/site/_site. If
you'd like the generated site placed somewhere else:
There is an autobuild feature that will regenerate your site if any of the files change:
$ jekyll /path/to/place/generated/site
And if you don't want to be in the proto site root to run Jekyll:
$ jekyll /path/to/proto/site /path/to/place/generated/site
h2. Run Options
There is an autobuild feature that will regenerate your site if any of the
files change. The autobuild feature can be used on any of the invocations:
$ jekyll --auto
@ -50,32 +106,155 @@ enable it (it may take some time to run if you have many posts):
$ jekyll --lsi
If you'd like the generated site placed somewhere else:
For static code highlighting, you can install Pygments (see below) and then
use that to make your code blocks look pretty. To activate Pygments support
during the conversion:
$ jekyll /path/to/place/generated/site
$ jekyll --pygments
And if you don't want to be in the proto site root to run Jekyll:
h2. Data
$ jekyll /path/to/proto/site /path/to/place/generated/site
The autobuild feature can be used on any of the invocations.
Jekyll traverses your site looking for files to process. Any files with YAML
front matter (see below) are subject to processing. For each of these files,
Jekyll makes a variety of data available to the pages via the Liquid
templating system. The following is a reference of the available data.
h3. Global
site
Sitewide information.
page
For Posts, this is the union of the data in the YAML front matter and the
computed data (such as URL and date). For regular pages, this is just the
YAML front matter.
content
In layout files, this contains the content of the subview(s). In Posts or
pages, this is undefined.
h3. Site
site.time
The current Time (when you run the jekyll command).
site.posts
A reverse chronological list of all Posts.
site.related_posts
If the page being processed is a Post, this contains a list of up to ten
related Posts. By default, these are low quality but fast to compute. For
high quality but slow to compute results, run the jekyll command with the
--lsi (latent semantic indexing) option.
h3. Post
post.title
The title of the Post.
post.url
The URL of the Post without the domain.
e.g. /2008/12/14/my-post.html
post.date
The Date assigned to the Post.
post.id
An identifier unique to the Post (useful in RSS feeds).
e.g. /2008/12/14/my-post
post.content
The content of the Post.
h2. YAML Front Matter
Any files that contain a YAML front matter block will be processed by Jekyll
as special files. The front matter must be the first thing in the file and
takes the form of:
<pre>
---
layout: post
title: Blogging Like a Hacker
---
</pre>
Between the triple-dashed lines, you can set predefined variables (see below
for a reference) or custom data of your own.
h3. Predefined Global Variables
layout
If set, this specifies the layout file to use. Use the layout file
name without file extension. Layout files must be placed in the
<code>_layouts</code> directory.
h3. Predefined Post Variables
permalink
If you need your processed URLs to be something other than the default
/year/month/day/title.html then you can set this variable and it will
be used as the final URL.
h3. Custom Variables
Any variables in the front matter that are not predefined are mixed into the
data that is sent to the Liquid templating engine during the conversion. For
instance, if you set a <code>title</code>, you can use that in your layout to
set the page title:
<pre>
<title>{{ page.title }}</title>
</pre>
h2. Filters, Tags, and Blocks
h3. Include Tag
In addition to the built-in Liquid filters, tags, and blocks, Jekyll provides
some additional items that you can use in your site.
h3. Date to XML Schema (Filter)
Convert a Time into XML Schema format.
{{ site.time | date_to_xmlschema }}
becomes
2008-11-17T13:07:54-08:00
h3. XML Escape (Filter)
Escape some text for use in XML.
{{ post.content | xml_escape }}
h3. Number of Words (Filter)
Count the number of words in some text.
{{ post.content | number_of_words }}
becomes
1337
h3. Include (Tag)
If you have small page fragments that you wish to include in multiple places on your site, you can use the <code>include</code> tag.
<pre>{% include sig.textile %}</pre>
Jekyll expects all include files to be placed in an <code>_includes</code> directory at the root of your source dir. So this will embed the contents of <code>/path/to/proto/site/_includes/sig.textile</code> into the calling file.
Jekyll expects all include files to be placed in an <code>_includes</code>
directory at the root of your source dir. So this will embed the contents of
<code>/path/to/proto/site/_includes/sig.textile</code> into the calling file.
h3. Code Highlighting Block
h3. Code Highlighting (Block)
Jekyll has built in support for syntax highlighting of over "100
languages":http://pygments.org/languages/ via "Pygments":http://pygments.org/.
In order to take advantage of this you'll need to have Pygments installed, and
the pygmentize binary must be in your path. When you run Jekyll, make sure you run it with Pygments support:
the pygmentize binary must be in your path. When you run Jekyll, make sure you
run it with Pygments support:
$ jekyll --pygments

View File

@ -1,10 +1,10 @@
Gem::Specification.new do |s|
s.name = %q{jekyll}
s.version = "0.1.6"
s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tom Preston-Werner"]
s.date = %q{2008-12-13}
s.date = %q{2008-12-14}
s.default_executable = %q{jekyll}
s.email = ["tom@mojombo.com"]
s.executables = ["jekyll"]

View File

@ -30,7 +30,7 @@ require 'jekyll/tags/include'
require 'jekyll/albino'
module Jekyll
VERSION = '0.1.6'
VERSION = '0.2.0'
class << self
attr_accessor :source, :dest, :lsi, :pygments

View File

@ -74,8 +74,7 @@ module Jekyll
def permalink
self.data && self.data['permalink']
end
# The generated relative url of this post
# e.g. /2008/11/05/my-awesome-post.html
#
@ -122,8 +121,8 @@ module Jekyll
def add_layout(layouts, site_payload)
# construct post payload
related = related_posts(site_payload["site"]["posts"])
payload = {"page" => self.to_liquid.merge(self.data), "related_posts" => related}
do_layout(payload, layouts, site_payload)
payload = {"page" => self.to_liquid.merge(self.data)}
do_layout(payload, layouts, site_payload.merge({"site" => {"related_posts" => related}}))
end
# Write the generated post file to the destination directory.